author | Junio C Hamano <gitster@pobox.com> | |
Thu, 16 Feb 2012 22:08:00 +0000 (14:08 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 16 Feb 2012 22:08:00 +0000 (14:08 -0800) |
* jc/maint-commit-ignore-i-t-a:
commit: ignore intent-to-add entries instead of refusing
Conflicts:
cache-tree.c
commit: ignore intent-to-add entries instead of refusing
Conflicts:
cache-tree.c
cache-tree.c | patch | blob | history | |
t/t2203-add-intent.sh | patch | blob | history |
diff --git a/cache-tree.c b/cache-tree.c
index 8de39590d57e14d08ee4d04b74965191aa905b29..bf03cb7fcefdc7e119203f096b367592d5b7cf8c 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) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
+ if (ce_stage(ce)) {
if (silent)
return -1;
if (10 < ++funny) {
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 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 25435290a71ae8031762a3e63537fd3a23a8fc90..ec35409f9cbe9bcdd3d21a6a5a15996b165d2fff 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_expect_success 'i-t-a entry is simply ignored' '
test_tick &&
git commit -a -m initial &&
git reset --hard &&
echo frotz >nitfol &&
git add rezrov &&
git add -N nitfol &&
- test_must_fail git commit -m initial
+ git commit -m second &&
+ test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
+ test $(git diff --name-only HEAD -- nitfol | wc -l) = 1
'
test_expect_success 'can commit with an unrelated i-t-a entry in index' '
git reset --hard &&
- echo xyzzy >rezrov &&
+ echo bozbar >rezrov &&
echo frotz >nitfol &&
git add rezrov &&
git add -N nitfol &&