Skip to content

Commit 6c63ab3

Browse files
committed
Merge branch 'jc/maint-commit-ignore-i-t-a' into maint
* jc/maint-commit-ignore-i-t-a: commit: ignore intent-to-add entries instead of refusing Conflicts: cache-tree.c
2 parents c6a4e3f + 3f6d56d commit 6c63ab3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

cache-tree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int verify_cache(struct cache_entry **cache,
158158
funny = 0;
159159
for (i = 0; i < entries; i++) {
160160
struct cache_entry *ce = cache[i];
161-
if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
161+
if (ce_stage(ce)) {
162162
if (silent)
163163
return -1;
164164
if (10 < ++funny) {
@@ -338,8 +338,8 @@ static int update_one(struct cache_tree *it,
338338
mode, sha1_to_hex(sha1), entlen+baselen, path);
339339
}
340340

341-
if (ce->ce_flags & CE_REMOVE)
342-
continue; /* entry being removed */
341+
if (ce->ce_flags & (CE_REMOVE | CE_INTENT_TO_ADD))
342+
continue; /* entry being removed or placeholder */
343343

344344
strbuf_grow(&buffer, entlen + 100);
345345
strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');

t/t2203-add-intent.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test_expect_success 'intent to add does not clobber existing paths' '
3232
! grep "$empty" actual
3333
'
3434

35-
test_expect_success 'cannot commit with i-t-a entry' '
35+
test_expect_success 'i-t-a entry is simply ignored' '
3636
test_tick &&
3737
git commit -a -m initial &&
3838
git reset --hard &&
@@ -41,12 +41,14 @@ test_expect_success 'cannot commit with i-t-a entry' '
4141
echo frotz >nitfol &&
4242
git add rezrov &&
4343
git add -N nitfol &&
44-
test_must_fail git commit -m initial
44+
git commit -m second &&
45+
test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
46+
test $(git diff --name-only HEAD -- nitfol | wc -l) = 1
4547
'
4648

4749
test_expect_success 'can commit with an unrelated i-t-a entry in index' '
4850
git reset --hard &&
49-
echo xyzzy >rezrov &&
51+
echo bozbar >rezrov &&
5052
echo frotz >nitfol &&
5153
git add rezrov &&
5254
git add -N nitfol &&

0 commit comments

Comments
 (0)