summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 388b2ac)
raw | patch | inline | side by side (parent: 388b2ac)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 29 Nov 2008 03:56:34 +0000 (19:56 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 1 Dec 2008 01:59:19 +0000 (17:59 -0800) |
Writing a tree out of an index with an "intent to add" entry is blocked.
This implies that you cannot "git commit" from such a state; however you
can still do "git commit -a" or "git commit $that_path".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This implies that you cannot "git commit" from such a state; however you
can still do "git commit -a" or "git commit $that_path".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/builtin-commit.c b/builtin-commit.c
index 1677e6b45f112857ecae1c5ddccf9eb6a3d11f2a..2b499fa543e4fd969ee0dcf1e878cbe19f4ba02f 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
active_cache_tree = cache_tree();
if (cache_tree_update(active_cache_tree,
active_cache, active_nr, 0, 0) < 0) {
- error("Error building trees; the index is unmerged?");
+ error("Error building trees");
return 0;
}
diff --git a/builtin-write-tree.c b/builtin-write-tree.c
index 52a3c015ff8e4611522bd41078bdb2934d288d35..9d640508dd8eb62201b286490b7f83486470d611 100644 (file)
--- a/builtin-write-tree.c
+++ b/builtin-write-tree.c
die("%s: error reading the index", me);
break;
case WRITE_TREE_UNMERGED_INDEX:
- die("%s: error building trees; the index is unmerged?", me);
+ die("%s: error building trees", 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 5f8ee87bb1c446341b640c2f978a658d6bfcfcd0..3d8f218a5f9e838b15e1d56113a4dd56904ee544 100644 (file)
--- a/cache-tree.c
+++ b/cache-tree.c
funny = 0;
for (i = 0; i < entries; i++) {
struct cache_entry *ce = cache[i];
- if (ce_stage(ce)) {
+ if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
if (10 < ++funny) {
fprintf(stderr, "...\n");
break;
}
- fprintf(stderr, "%s: unmerged (%s)\n",
- ce->name, sha1_to_hex(ce->sha1));
+ 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);
}
}
if (funny)
diff --git a/read-cache.c b/read-cache.c
index fa30a0f88577be6ec33832ea34f8a71e7ba6b0ea..8579663ee09b1e01cf5228bd8be7c5eb371c5d31 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
if (!ignore_valid && (ce->ce_flags & CE_VALID))
return 0;
+ /*
+ * Intent-to-add entries have not been added, so the index entry
+ * by definition never matches what is in the work tree until it
+ * actually gets added.
+ */
+ if (ce->ce_flags & CE_INTENT_TO_ADD)
+ return DATA_CHANGED | TYPE_CHANGED | MODE_CHANGED;
+
changed = ce_match_stat_basic(ce, st);
/*
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index d4de35ea067c4a7c3a9a46ceac57f4cf1086a19a..58a329961e5c269e1b035558db890c9e30375147 100755 (executable)
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
! grep "$empty" actual
'
+test_expect_success 'cannot commit with i-t-a entry' '
+ test_tick &&
+ git commit -a -m initial &&
+ git reset --hard &&
+
+ echo xyzzy >rezrov &&
+ echo frotz >nitfol &&
+ git add rezrov &&
+ git add -N nitfol &&
+ test_must_fail git commit
+'
+
+test_expect_success 'can commit with an unrelated i-t-a entry in index' '
+ git reset --hard &&
+ echo xyzzy >rezrov &&
+ echo frotz >nitfol &&
+ git add rezrov &&
+ git add -N nitfol &&
+ git commit -m partial rezrov
+'
+
+test_expect_success 'can "commit -a" with an i-t-a entry' '
+ git reset --hard &&
+ : >nitfol &&
+ git add -N nitfol &&
+ git commit -a -m all
+'
+
test_done