mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'vn/restore-empty-ita-corner-case-fix'
"git checkout" and "git restore" to re-populate the index from a tree-ish (typically HEAD) did not work correctly for a path that was removed and then added again with the intent-to-add bit, when the corresponding working tree file was empty. This has been corrected. * vn/restore-empty-ita-corner-case-fix: restore: add test for deleted ita files checkout.c: unstage empty deleted ita files
This commit is contained in:
commit
072735ea58
|
@ -126,6 +126,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
|
|||
if (pos >= 0) {
|
||||
struct cache_entry *old = active_cache[pos];
|
||||
if (ce->ce_mode == old->ce_mode &&
|
||||
!ce_intent_to_add(old) &&
|
||||
oideq(&ce->oid, &old->oid)) {
|
||||
old->ce_flags |= CE_UPDATE;
|
||||
discard_cache_entry(ce);
|
||||
|
|
|
@ -78,4 +78,15 @@ test_expect_success 'do not touch files that are already up-to-date' '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'checkout HEAD adds deleted intent-to-add file back to index' '
|
||||
echo "nonempty" >nonempty &&
|
||||
>empty &&
|
||||
git add nonempty empty &&
|
||||
git commit -m "create files to be deleted" &&
|
||||
git rm --cached nonempty empty &&
|
||||
git add -N nonempty empty &&
|
||||
git checkout HEAD nonempty empty &&
|
||||
git diff --cached --exit-code
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
|
@ -95,4 +95,15 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' '
|
|||
)
|
||||
'
|
||||
|
||||
test_expect_success 'restore --staged adds deleted intent-to-add file back to index' '
|
||||
echo "nonempty" >nonempty &&
|
||||
>empty &&
|
||||
git add nonempty empty &&
|
||||
git commit -m "create files to be deleted" &&
|
||||
git rm --cached nonempty empty &&
|
||||
git add -N nonempty empty &&
|
||||
git restore --staged nonempty empty &&
|
||||
git diff --cached --exit-code
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue