@matheusbsbs / matheus-bagliano / commits / 74da98f9c7
Fork 0

unpack-trees: mark new entries skip-worktree appropriately

Sparse checkout narrows worktree down based on the skip-worktree bit before and after $GIT_DIR/info/sparse-checkout application. If it does not have that bit before but does after, a narrow is detected and the file will be removed from worktree. New files added by merge, however, does not have skip-worktree bit. If those files appear to be outside checkout area, the same rule applies: the file gets removed from worktree even though they don't exist in worktree. Just pretend they have skip-worktree before in that case, so the rule is ignored. 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>

Nguyễn Thái Ngọc Duy committed Jul 31, 2010 at 13:14 UTC 74da98f9c761b2e63366a643fa52749844ddc6a1
2 files changed +3 -1
t/t1011-read-tree-sparse-checkout.sh
+1 -1
@@ -146,7 +146,7 @@ test_expect_success 'read-tree adds to worktree, absent case' '
146 test ! -f sub/added
147 '
148
149 -test_expect_failure 'read-tree adds to worktree, dirty case' '
149 +test_expect_success 'read-tree adds to worktree, dirty case' '
150 echo init.t >.git/info/sparse-checkout &&
151 git checkout -f removed &&
152 mkdir sub &&
unpack-trees.c
+2
@@ -1096,6 +1096,8 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
1096 if (!old) {
1097 if (verify_absent(merge, "overwritten", o))
1098 return -1;
1099 + if (!o->skip_sparse_checkout && will_have_skip_worktree(merge, o))
1100 + update |= CE_SKIP_WORKTREE;
1101 invalidate_ce_path(merge, o);
1102 } else if (!(old->ce_flags & CE_CONFLICTED)) {
1103 /*