From: Junio C Hamano Date: Wed, 22 Jan 2020 23:07:32 +0000 (-0800) Subject: Merge branch 'nd/switch-and-restore' X-Git-Tag: v2.26.0-rc0~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09e393d913072d7765b02aba1210d843a83cfbae;p=thirdparty%2Fgit.git Merge branch 'nd/switch-and-restore' "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 --- 09e393d913072d7765b02aba1210d843a83cfbae diff --cc t/t2070-restore.sh index 21c3f84459,9f40f96069..076d0df7fc --- a/t/t2070-restore.sh +++ b/t/t2070-restore.sh @@@ -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