Skip to content

Commit 341003e

Browse files
pcloudsgitster
authored andcommitted
kill limit_pathspec_to_literal() as it's only used by parse_pathspec()
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 233c3e6 commit 341003e

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

dir.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,14 +1473,6 @@ int remove_path(const char *name)
14731473
return 0;
14741474
}
14751475

1476-
int limit_pathspec_to_literal(void)
1477-
{
1478-
static int flag = -1;
1479-
if (flag < 0)
1480-
flag = git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT, 0);
1481-
return flag;
1482-
}
1483-
14841476
/*
14851477
* Frees memory within dir which was allocated for exclude lists and
14861478
* the exclude_stack. Does not free dir itself.

pathspec.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
9191
const char *prefix, int prefixlen,
9292
const char *elt)
9393
{
94+
static int literal_global = -1;
9495
unsigned magic = 0, short_magic = 0;
9596
const char *copyfrom = elt, *long_magic_end = NULL;
9697
char *match;
9798
int i, pathspec_prefix = -1;
9899

100+
if (literal_global < 0)
101+
literal_global = git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT, 0);
102+
99103
if (elt[0] != ':') {
100104
; /* nothing to do */
101105
} else if (elt[1] == '(') {
@@ -184,7 +188,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
184188
if (flags & PATHSPEC_PREFIX_ORIGIN) {
185189
struct strbuf sb = STRBUF_INIT;
186190
const char *start = elt;
187-
if (prefixlen && !limit_pathspec_to_literal()) {
191+
if (prefixlen && !literal_global) {
188192
/* Preserve the actual prefix length of each pattern */
189193
if (long_magic_end) {
190194
strbuf_add(&sb, start, long_magic_end - start);
@@ -232,7 +236,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
232236
elt, ce_len, ce->name);
233237
}
234238

235-
if (limit_pathspec_to_literal())
239+
if (literal_global)
236240
item->nowildcard_len = item->len;
237241
else {
238242
item->nowildcard_len = simple_length(item->match);

pathspec.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ extern void parse_pathspec(struct pathspec *pathspec,
6161
extern void copy_pathspec(struct pathspec *dst, const struct pathspec *src);
6262
extern void free_pathspec(struct pathspec *);
6363

64-
extern int limit_pathspec_to_literal(void);
65-
6664
extern char *find_pathspecs_matching_against_index(const struct pathspec *pathspec);
6765
extern void add_pathspec_matches_against_index(const struct pathspec *pathspec, char *seen);
6866
extern const char *check_path_for_gitlink(const char *path);

0 commit comments

Comments
 (0)