sparse-checkout: update working directory in-process
The sparse-checkout builtin used 'git read-tree -mu HEAD' to update the skip-worktree bits in the index and to update the working directory. This extra process is overly complex, and prone to failure. It also requires that we write our changes to the sparse-checkout file before trying to update the index. Remove this extra process call by creating a direct call to unpack_trees() in the same way 'git read-tree -mu HEAD' does. In addition, provide an in-memory list of patterns so we can avoid reading from the sparse-checkout file. This allows us to test a proposed change to the file before writing to it. An earlier version of this patch included a bug when the 'set' command failed due to the "Sparse checkout leaves no entry on working directory" error. It would not rollback the index.lock file, so the replay of the old sparse-checkout specification would fail. A test in t1091 now covers that scenario. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e9de487aa3
commit
e091228e17
@ -1511,7 +1511,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||
memset(&pl, 0, sizeof(pl));
|
||||
if (!core_apply_sparse_checkout || !o->update)
|
||||
o->skip_sparse_checkout = 1;
|
||||
if (!o->skip_sparse_checkout) {
|
||||
if (!o->skip_sparse_checkout && !o->pl) {
|
||||
char *sparse = git_pathdup("info/sparse-checkout");
|
||||
pl.use_cone_patterns = core_sparse_checkout_cone;
|
||||
if (add_patterns_from_file_to_list(sparse, "", 0, &pl, NULL) < 0)
|
||||
@ -1684,7 +1684,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||
|
||||
done:
|
||||
trace_performance_leave("unpack_trees");
|
||||
clear_pattern_list(&pl);
|
||||
if (!o->keep_pattern_list)
|
||||
clear_pattern_list(&pl);
|
||||
return ret;
|
||||
|
||||
return_failed:
|
||||
|
Reference in New Issue
Block a user