Skip to content

Commit f1f523e

Browse files
pcloudsgitster
authored andcommitted
unpack-trees(): ignore worktree check outside checkout area
verify_absent() and verify_uptodate() are used to ensure worktree is safe to be updated, then CE_REMOVE or CE_UPDATE will be set. Finally check_updates() bases on CE_REMOVE, CE_UPDATE and the recently added CE_WT_REMOVE to update working directory accordingly. The entries that are checked may eventually be left out of checkout area (done later in apply_sparse_checkout()). We don't want to update outside checkout area. This patch teaches Git to assume "good", skip these checks when it's sure those entries will be outside checkout area, and clear CE_REMOVE|CE_UPDATE that could be set due to this assumption. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e800ec9 commit f1f523e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

unpack-trees.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,14 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
505505
ret = -1;
506506
goto done;
507507
}
508+
/*
509+
* Merge strategies may set CE_UPDATE|CE_REMOVE outside checkout
510+
* area as a result of ce_skip_worktree() shortcuts in
511+
* verify_absent() and verify_uptodate(). Clear them.
512+
*/
513+
if (ce_skip_worktree(ce))
514+
ce->ce_flags &= ~(CE_UPDATE | CE_REMOVE);
515+
508516
}
509517
}
510518

@@ -577,6 +585,8 @@ static int verify_uptodate_1(struct cache_entry *ce,
577585
static int verify_uptodate(struct cache_entry *ce,
578586
struct unpack_trees_options *o)
579587
{
588+
if (!o->skip_sparse_checkout && will_have_skip_worktree(ce, o))
589+
return 0;
580590
return verify_uptodate_1(ce, o, ERRORMSG(o, not_uptodate_file));
581591
}
582592

@@ -776,6 +786,8 @@ static int verify_absent_1(struct cache_entry *ce, const char *action,
776786
static int verify_absent(struct cache_entry *ce, const char *action,
777787
struct unpack_trees_options *o)
778788
{
789+
if (!o->skip_sparse_checkout && will_have_skip_worktree(ce, o))
790+
return 0;
779791
return verify_absent_1(ce, action, o, ERRORMSG(o, would_lose_untracked));
780792
}
781793

0 commit comments

Comments
 (0)