diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-07-31 13:14:27 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-08-09 12:16:01 -0700 |
commit | 700e66d66100fff952ffca439834a6deb1062d11 (patch) | |
tree | 92a1ccac554f8f650066969ae658660463e2767c /t/t1011-read-tree-sparse-checkout.sh | |
parent | eec3fc03092e308694d56b875a858065730822e2 (diff) | |
download | git-700e66d66100fff952ffca439834a6deb1062d11.tar.gz |
unpack-trees: let read-tree -u remove index entries outside sparse area
To avoid touching the worktree outside a sparse checkout,
when the update flag is enabled unpack_trees() clears the
CE_UPDATE and CE_REMOVE flags on entries that do not match the
sparse pattern before actually committing any updates to the
index file or worktree.
The effect on the index was unintentional; sparse checkout was
never meant to prevent index updates outside the area checked
out. And the result is very confusing: for example, after a
failed merge, currently "git reset --hard" does not reset the
state completely but an additional "git reset --mixed" will.
So stop clearing the CE_REMOVE flag. Instead, maintain a
CE_WT_REMOVE flag to separately track whether a particular
file removal should apply to the worktree in addition to the
index or not.
The CE_WT_REMOVE flag is used already to mark files that
should be removed because of a narrowing checkout area. That
usage will still apply; do not clear the CE_WT_REMOVE flag
in that case (detectable because the CE_REMOVE flag is not
set).
This bug masked some other bugs illustrated by the test
suite, which will be addressed by later patches.
Reported-by: Frédéric Brière <fbriere@fbriere.net>
Fixes: http://bugs.debian.org/583699
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1011-read-tree-sparse-checkout.sh')
-rwxr-xr-x | t/t1011-read-tree-sparse-checkout.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index 81ab4c6f37..85e08374dd 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -146,7 +146,7 @@ test_expect_success 'read-tree adds to worktree, absent case' ' test ! -f sub/added ' -test_expect_success 'read-tree adds to worktree, dirty case' ' +test_expect_failure 'read-tree adds to worktree, dirty case' ' echo init.t >.git/info/sparse-checkout && git checkout -f removed && mkdir sub && @@ -167,4 +167,13 @@ test_expect_success 'index removal and worktree narrowing at the same time' ' test_cmp empty result ' +test_expect_success 'read-tree --reset removes outside worktree' ' + >empty && + echo init.t >.git/info/sparse-checkout && + git checkout -f top && + git reset --hard removed && + git ls-files sub/added >result && + test_cmp empty result +' + test_done |