Skip to content

Commit

Permalink
unpack-trees: mark new entries skip-worktree appropriately
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 9, 2010
1 parent 711f151 commit 74da98f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test_expect_success 'read-tree adds to worktree, absent case' '
test ! -f sub/added
'

test_expect_failure 'read-tree adds to worktree, dirty case' '
test_expect_success 'read-tree adds to worktree, dirty case' '
echo init.t >.git/info/sparse-checkout &&
git checkout -f removed &&
mkdir sub &&
Expand Down
2 changes: 2 additions & 0 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,8 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
if (!old) {
if (verify_absent(merge, "overwritten", o))
return -1;
if (!o->skip_sparse_checkout && will_have_skip_worktree(merge, o))
update |= CE_SKIP_WORKTREE;
invalidate_ce_path(merge, o);
} else if (!(old->ce_flags & CE_CONFLICTED)) {
/*
Expand Down

0 comments on commit 74da98f

Please sign in to comment.