Skip to content

Commit 576de3d

Browse files
newrengitster
authored andcommitted
unpack_trees: start splitting internal fields from public API
This just splits the two fields already marked as internal-only into a separate internal struct. Future commits will add more fields that were meant to be internal-only but were not explicitly marked as such to the same struct. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33b1b4c commit 576de3d

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

unpack-trees.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ static void populate_from_existing_patterns(struct unpack_trees_options *o,
18091809
if (get_sparse_checkout_patterns(pl) < 0)
18101810
o->skip_sparse_checkout = 1;
18111811
else
1812-
o->pl = pl;
1812+
o->internal.pl = pl;
18131813
}
18141814

18151815
static void update_sparsity_for_prefix(const char *prefix,
@@ -1871,10 +1871,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18711871

18721872
if (len > MAX_UNPACK_TREES)
18731873
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
1874-
if (o->dir)
1875-
BUG("o->dir is for internal use only");
1876-
if (o->pl)
1877-
BUG("o->pl is for internal use only");
1874+
if (o->internal.dir)
1875+
BUG("o->internal.dir is for internal use only");
1876+
if (o->internal.pl)
1877+
BUG("o->internal.pl is for internal use only");
18781878

18791879
trace_performance_enter();
18801880
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
@@ -1891,9 +1891,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18911891
BUG("UNPACK_RESET_OVERWRITE_UNTRACKED incompatible with preserved ignored files");
18921892

18931893
if (!o->preserve_ignored) {
1894-
o->dir = &dir;
1895-
o->dir->flags |= DIR_SHOW_IGNORED;
1896-
setup_standard_excludes(o->dir);
1894+
o->internal.dir = &dir;
1895+
o->internal.dir->flags |= DIR_SHOW_IGNORED;
1896+
setup_standard_excludes(o->internal.dir);
18971897
}
18981898

18991899
if (o->prefix)
@@ -1943,7 +1943,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
19431943
* Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
19441944
*/
19451945
if (!o->skip_sparse_checkout)
1946-
mark_new_skip_worktree(o->pl, o->src_index, 0,
1946+
mark_new_skip_worktree(o->internal.pl, o->src_index, 0,
19471947
CE_NEW_SKIP_WORKTREE, o->verbose_update);
19481948

19491949
if (!dfc)
@@ -2009,7 +2009,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
20092009
* If they will have NEW_SKIP_WORKTREE, also set CE_SKIP_WORKTREE
20102010
* so apply_sparse_checkout() won't attempt to remove it from worktree
20112011
*/
2012-
mark_new_skip_worktree(o->pl, &o->result,
2012+
mark_new_skip_worktree(o->internal.pl, &o->result,
20132013
CE_ADDED, CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE,
20142014
o->verbose_update);
20152015

@@ -2067,9 +2067,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
20672067
done:
20682068
if (free_pattern_list)
20692069
clear_pattern_list(&pl);
2070-
if (o->dir) {
2071-
dir_clear(o->dir);
2072-
o->dir = NULL;
2070+
if (o->internal.dir) {
2071+
dir_clear(o->internal.dir);
2072+
o->internal.dir = NULL;
20732073
}
20742074
trace2_region_leave("unpack_trees", "unpack_trees", the_repository);
20752075
trace_performance_leave("unpack_trees");
@@ -2117,14 +2117,14 @@ enum update_sparsity_result update_sparsity(struct unpack_trees_options *o,
21172117
pl = xcalloc(1, sizeof(*pl));
21182118
populate_from_existing_patterns(o, pl);
21192119
}
2120-
o->pl = pl;
2120+
o->internal.pl = pl;
21212121

21222122
/* Expand sparse directories as needed */
2123-
expand_index(o->src_index, o->pl);
2123+
expand_index(o->src_index, o->internal.pl);
21242124

21252125
/* Set NEW_SKIP_WORKTREE on existing entries. */
21262126
mark_all_ce_unused(o->src_index);
2127-
mark_new_skip_worktree(o->pl, o->src_index, 0,
2127+
mark_new_skip_worktree(o->internal.pl, o->src_index, 0,
21282128
CE_NEW_SKIP_WORKTREE, o->verbose_update);
21292129

21302130
/* Then loop over entries and update/remove as needed */
@@ -2152,7 +2152,7 @@ enum update_sparsity_result update_sparsity(struct unpack_trees_options *o,
21522152
if (free_pattern_list) {
21532153
clear_pattern_list(pl);
21542154
free(pl);
2155-
o->pl = NULL;
2155+
o->internal.pl = NULL;
21562156
}
21572157
trace_performance_leave("update_sparsity");
21582158
return ret;
@@ -2340,7 +2340,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
23402340
pathbuf = xstrfmt("%.*s/", namelen, ce->name);
23412341

23422342
memset(&d, 0, sizeof(d));
2343-
if (o->dir)
2343+
if (o->internal.dir)
23442344
setup_standard_excludes(&d);
23452345
i = read_directory(&d, o->src_index, pathbuf, namelen+1, NULL);
23462346
dir_clear(&d);
@@ -2395,8 +2395,8 @@ static int check_ok_to_remove(const char *name, int len, int dtype,
23952395
if (ignore_case && icase_exists(o, name, len, st))
23962396
return 0;
23972397

2398-
if (o->dir &&
2399-
is_excluded(o->dir, o->src_index, name, &dtype))
2398+
if (o->internal.dir &&
2399+
is_excluded(o->internal.dir, o->src_index, name, &dtype))
24002400
/*
24012401
* ce->name is explicitly excluded, so it is Ok to
24022402
* overwrite it.

unpack-trees.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,12 @@ struct unpack_trees_options {
9797
struct index_state *src_index;
9898
struct index_state result;
9999

100-
struct pattern_list *pl; /* for internal use */
101-
struct dir_struct *dir; /* for internal use only */
102100
struct checkout_metadata meta;
101+
102+
struct unpack_trees_options_internal {
103+
struct pattern_list *pl;
104+
struct dir_struct *dir;
105+
} internal;
103106
};
104107

105108
int unpack_trees(unsigned n, struct tree_desc *t,

0 commit comments

Comments
 (0)