]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'nd/switch-and-restore' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Feb 2020 20:42:29 +0000 (12:42 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Feb 2020 20:42:29 +0000 (12:42 -0800)
"git restore --staged" did not correctly update the cache-tree
structure, resulting in bogus trees to be written afterwards, which
has been corrected.

* nd/switch-and-restore:
  restore: invalidate cache-tree when removing entries with --staged

1  2 
builtin/checkout.c
t/t2070-restore.sh

Simple merge
index 21c3f84459dfe29053bbb0d9a43160a6df33f737,9f40f9606934d6445e9ba228042781631168f2c5..076d0df7fc0602e8d47c03ffa6ddb6dff0b985a9
@@@ -95,15 -95,21 +95,32 @@@ test_expect_success 'restore --ignore-u
        )
  '
  
 +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_expect_success 'restore --staged invalidates cache tree for deletions' '
+       test_when_finished git reset --hard &&
+       >new1 &&
+       >new2 &&
+       git add new1 new2 &&
+       # It is important to commit and then reset here, so that the index
+       # contains a valid cache-tree for the "both" tree.
+       git commit -m both &&
+       git reset --soft HEAD^ &&
+       git restore --staged new1 &&
+       git commit -m "just new2" &&
+       git rev-parse HEAD:new2 &&
+       test_must_fail git rev-parse HEAD:new1
+ '
  test_done