All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] nd/commit-ignore-i-t-a replacement
@ 2012-01-16  2:36 Nguyễn Thái Ngọc Duy
  2012-01-16  2:36 ` [PATCH 1/2] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
  2012-01-16  2:36 ` [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-01-16  2:36 UTC (permalink / raw)
  To: git; +Cc: Jonathan Nieder, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

This replaces current topic branch in pu with a more sensible
approach using config key. write-tree also learns about this.

Nguyễn Thái Ngọc Duy (2):
  cache-tree: update API to take abitrary flags
  commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing
    trees

 Documentation/config.txt         |    5 +++++
 Documentation/git-add.txt        |   12 ++++++++++--
 Documentation/git-write-tree.txt |    8 +++++++-
 builtin/commit.c                 |   13 ++++++++++---
 builtin/write-tree.c             |    2 ++
 cache-tree.c                     |   35 +++++++++++++++++------------------
 cache-tree.h                     |    5 ++++-
 merge-recursive.c                |    2 +-
 t/t2203-add-intent.sh            |   30 ++++++++++++++++++++++++++++++
 test-dump-cache-tree.c           |    2 +-
 10 files changed, 87 insertions(+), 27 deletions(-)

-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH RFC] commit: allow to commit even if there are intent-to-add entries
@ 2012-01-11  6:01 Nguyễn Thái Ngọc Duy
  2012-01-11  9:59 ` [PATCH 1/2] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
  0 siblings, 1 reply; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-01-11  6:01 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

This patch replaces the approach in 331fcb5 (git add --intent-to-add:
do not let an empty blob be committed by accident) regarding i-t-a
entries: instead of forbidding i-t-a entries at commit time, we can
simply ignore them.

We already ignore CE_REMOVE entries while updating cache-tree. Putting
CE_INTENT_TO_ADD ones in the same category should not cause any negative
effects regarding cache-tree.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 On the few chances I have to use "git add -N" it does not fit well
 with "git add -p; git diff --cached; git commit -m foo" style. I
 think this may be a good thing to do.

 builtin/commit.c      |    2 +-
 builtin/write-tree.c  |    2 +-
 cache-tree.c          |   14 +++++---------
 t/t2203-add-intent.sh |   10 +++++++++-
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index eba1377..767b78a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -871,7 +871,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	discard_cache();
 	read_cache_from(index_file);
 	if (update_main_cache_tree(0)) {
-		error(_("Error building trees"));
+		error(_("Error building trees; the index is unmerged?"));
 		return 0;
 	}
 
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index b223af4..68baa24 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -46,7 +46,7 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
 		die("%s: error reading the index", me);
 		break;
 	case WRITE_TREE_UNMERGED_INDEX:
-		die("%s: error building trees", me);
+		die("%s: error building trees; the index is unmerged?", me);
 		break;
 	case WRITE_TREE_PREFIX_ERROR:
 		die("%s: prefix %s not found", me, prefix);
diff --git a/cache-tree.c b/cache-tree.c
index 8de3959..47defd1 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -158,19 +158,15 @@ static int verify_cache(struct cache_entry **cache,
 	funny = 0;
 	for (i = 0; i < entries; i++) {
 		struct cache_entry *ce = cache[i];
-		if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
+		if (ce_stage(ce)) {
 			if (silent)
 				return -1;
 			if (10 < ++funny) {
 				fprintf(stderr, "...\n");
 				break;
 			}
-			if (ce_stage(ce))
-				fprintf(stderr, "%s: unmerged (%s)\n",
-					ce->name, sha1_to_hex(ce->sha1));
-			else
-				fprintf(stderr, "%s: not added yet\n",
-					ce->name);
+			fprintf(stderr, "%s: unmerged (%s)\n",
+				ce->name, sha1_to_hex(ce->sha1));
 		}
 	}
 	if (funny)
@@ -338,8 +334,8 @@ static int update_one(struct cache_tree *it,
 				mode, sha1_to_hex(sha1), entlen+baselen, path);
 		}
 
-		if (ce->ce_flags & CE_REMOVE)
-			continue; /* entry being removed */
+		if (ce->ce_flags & (CE_REMOVE | CE_INTENT_TO_ADD))
+			continue; /* entry being removed or just placeholder */
 
 		strbuf_grow(&buffer, entlen + 100);
 		strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 2543529..65430e4 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -41,7 +41,15 @@ test_expect_success 'cannot commit with i-t-a entry' '
 	echo frotz >nitfol &&
 	git add rezrov &&
 	git add -N nitfol &&
-	test_must_fail git commit -m initial
+	git commit -m initial &&
+	git ls-tree -r HEAD >actual &&
+	cat >expected <<EOF &&
+100644 blob ce013625030ba8dba906f756967f9e9ca394464a	elif
+100644 blob ce013625030ba8dba906f756967f9e9ca394464a	file
+100644 blob cf7711b63209d0dbc2d030f7fe3513745a9880e4	rezrov
+EOF
+	test_cmp expected actual &&
+	git reset HEAD^
 '
 
 test_expect_success 'can commit with an unrelated i-t-a entry in index' '
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-01-17  2:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16  2:36 [PATCH 0/2] nd/commit-ignore-i-t-a replacement Nguyễn Thái Ngọc Duy
2012-01-16  2:36 ` [PATCH 1/2] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
2012-01-16  2:36 ` [PATCH 2/2] commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees Nguyễn Thái Ngọc Duy
2012-01-16 16:46   ` Pete Wyckoff
2012-01-16 23:21   ` Junio C Hamano
2012-01-17  1:50     ` Nguyen Thai Ngoc Duy
2012-01-17  2:47       ` Jonathan Nieder
  -- strict thread matches above, loose matches on Subject: below --
2012-01-11  6:01 [PATCH RFC] commit: allow to commit even if there are intent-to-add entries Nguyễn Thái Ngọc Duy
2012-01-11  9:59 ` [PATCH 1/2] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
2012-01-11 23:48   ` Junio C Hamano
2012-01-12  1:20     ` Nguyen Thai Ngoc Duy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.