Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-03-27 03:48:51 +0300
committerJunio C Hamano <gitster@pobox.com>2020-03-27 21:33:30 +0300
commit30e89c12f0afc5c4382b531973a5e82b60d402bd (patch)
tree11f51187371a62a33cf1a729dec9c100ca1f8a97 /unpack-trees.c
parent3cc7c50402ce1cbac9735da64844eb00bc096f46 (diff)
unpack-trees: pull sparse-checkout pattern reading into a new function
Create a populate_from_existing_patterns() function for reading the path_patterns from $GIT_DIR/info/sparse-checkout so that we can re-use it elsewhere. Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index e8e794880a..4733e7eaf8 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1492,6 +1492,20 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
clear_ce_flags(istate, select_flag, skip_wt_flag, pl, show_progress);
}
+static void populate_from_existing_patterns(struct unpack_trees_options *o,
+ struct pattern_list *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)
+ o->skip_sparse_checkout = 1;
+ else
+ o->pl = pl;
+ free(sparse);
+}
+
+
static int verify_absent(const struct cache_entry *,
enum unpack_trees_error_types,
struct unpack_trees_options *);
@@ -1512,18 +1526,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
trace_performance_enter();
- memset(&pl, 0, sizeof(pl));
if (!core_apply_sparse_checkout || !o->update)
o->skip_sparse_checkout = 1;
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)
- o->skip_sparse_checkout = 1;
- else
- o->pl = &pl;
- free(sparse);
+ memset(&pl, 0, sizeof(pl));
free_pattern_list = 1;
+ populate_from_existing_patterns(o, &pl);
}
memset(&o->result, 0, sizeof(o->result));