Skip to content

Commit 1679d60

Browse files
peffgitster
authored andcommitted
exclude: add flags parameter to add_patterns()
There are a number of callers of add_patterns() and its sibling functions. Let's give them a "flags" parameter for adding new options without having to touch each caller. We'll use this in a future patch to add O_NOFOLLOW support. But for now each caller just passes 0. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dbf387d commit 1679d60

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

builtin/sparse-checkout.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int sparse_checkout_list(int argc, const char **argv)
6464
pl.use_cone_patterns = core_sparse_checkout_cone;
6565

6666
sparse_filename = get_sparse_checkout_filename();
67-
res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL);
67+
res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0);
6868
free(sparse_filename);
6969

7070
if (res < 0) {
@@ -321,7 +321,7 @@ static int sparse_checkout_init(int argc, const char **argv)
321321
memset(&pl, 0, sizeof(pl));
322322

323323
sparse_filename = get_sparse_checkout_filename();
324-
res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL);
324+
res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0);
325325

326326
/* If we already have a sparse-checkout file, use it. */
327327
if (res >= 0) {
@@ -483,7 +483,7 @@ static void add_patterns_cone_mode(int argc, const char **argv,
483483
existing.use_cone_patterns = core_sparse_checkout_cone;
484484

485485
if (add_patterns_from_file_to_list(sparse_filename, "", 0,
486-
&existing, NULL))
486+
&existing, NULL, 0))
487487
die(_("unable to load existing sparse-checkout patterns"));
488488
free(sparse_filename);
489489

@@ -507,7 +507,7 @@ static void add_patterns_literal(int argc, const char **argv,
507507
{
508508
char *sparse_filename = get_sparse_checkout_filename();
509509
if (add_patterns_from_file_to_list(sparse_filename, "", 0,
510-
pl, NULL))
510+
pl, NULL, 0))
511511
die(_("unable to load existing sparse-checkout patterns"));
512512
free(sparse_filename);
513513
add_patterns_from_input(pl, argc, argv);

dir.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ static int add_patterns_from_buffer(char *buf, size_t size,
10461046
*/
10471047
static int add_patterns(const char *fname, const char *base, int baselen,
10481048
struct pattern_list *pl, struct index_state *istate,
1049-
struct oid_stat *oid_stat)
1049+
unsigned flags, struct oid_stat *oid_stat)
10501050
{
10511051
struct stat st;
10521052
int r;
@@ -1143,9 +1143,10 @@ static int add_patterns_from_buffer(char *buf, size_t size,
11431143

11441144
int add_patterns_from_file_to_list(const char *fname, const char *base,
11451145
int baselen, struct pattern_list *pl,
1146-
struct index_state *istate)
1146+
struct index_state *istate,
1147+
unsigned flags)
11471148
{
1148-
return add_patterns(fname, base, baselen, pl, istate, NULL);
1149+
return add_patterns(fname, base, baselen, pl, istate, flags, NULL);
11491150
}
11501151

11511152
int add_patterns_from_blob_to_list(
@@ -1194,7 +1195,7 @@ static void add_patterns_from_file_1(struct dir_struct *dir, const char *fname,
11941195
if (!dir->untracked)
11951196
dir->unmanaged_exclude_files++;
11961197
pl = add_pattern_list(dir, EXC_FILE, fname);
1197-
if (add_patterns(fname, "", 0, pl, NULL, oid_stat) < 0)
1198+
if (add_patterns(fname, "", 0, pl, NULL, 0, oid_stat) < 0)
11981199
die(_("cannot use %s as an exclude file"), fname);
11991200
}
12001201

@@ -1557,7 +1558,7 @@ static void prep_exclude(struct dir_struct *dir,
15571558
strbuf_addbuf(&sb, &dir->basebuf);
15581559
strbuf_addstr(&sb, dir->exclude_per_dir);
15591560
pl->src = strbuf_detach(&sb, NULL);
1560-
add_patterns(pl->src, pl->src, stk->baselen, pl, istate,
1561+
add_patterns(pl->src, pl->src, stk->baselen, pl, istate, 0,
15611562
untracked ? &oid_stat : NULL);
15621563
}
15631564
/*
@@ -3009,7 +3010,7 @@ int get_sparse_checkout_patterns(struct pattern_list *pl)
30093010
char *sparse_filename = get_sparse_checkout_filename();
30103011

30113012
pl->use_cone_patterns = core_sparse_checkout_cone;
3012-
res = add_patterns_from_file_to_list(sparse_filename, "", 0, pl, NULL);
3013+
res = add_patterns_from_file_to_list(sparse_filename, "", 0, pl, NULL, 0);
30133014

30143015
free(sparse_filename);
30153016
return res;

dir.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ int hashmap_contains_parent(struct hashmap *map,
420420
struct pattern_list *add_pattern_list(struct dir_struct *dir,
421421
int group_type, const char *src);
422422
int add_patterns_from_file_to_list(const char *fname, const char *base, int baselen,
423-
struct pattern_list *pl, struct index_state *istate);
423+
struct pattern_list *pl, struct index_state *istate,
424+
unsigned flags);
424425
void add_patterns_from_file(struct dir_struct *, const char *fname);
425426
int add_patterns_from_blob_to_list(struct object_id *oid,
426427
const char *base, int baselen,

0 commit comments

Comments
 (0)