@@ -70,6 +70,7 @@ static struct pathspec_magic {
7070 const char * name ;
7171} pathspec_magic [] = {
7272 { PATHSPEC_FROMTOP , '/' , "top" },
73+ { PATHSPEC_LITERAL , 0 , "literal" },
7374};
7475
7576/*
@@ -92,13 +93,15 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
9293 const char * elt )
9394{
9495 static int literal_global = -1 ;
95- unsigned magic = 0 , short_magic = 0 ;
96+ unsigned magic = 0 , short_magic = 0 , global_magic = 0 ;
9697 const char * copyfrom = elt , * long_magic_end = NULL ;
9798 char * match ;
9899 int i , pathspec_prefix = -1 ;
99100
100101 if (literal_global < 0 )
101102 literal_global = git_env_bool (GIT_LITERAL_PATHSPECS_ENVIRONMENT , 0 );
103+ if (literal_global )
104+ global_magic |= PATHSPEC_LITERAL ;
102105
103106 if (elt [0 ] != ':' ) {
104107 ; /* nothing to do */
@@ -164,6 +167,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
164167
165168 magic |= short_magic ;
166169 * p_short_magic = short_magic ;
170+ magic |= global_magic ;
167171
168172 if (pathspec_prefix >= 0 &&
169173 (prefixlen || (prefix && * prefix )))
@@ -236,7 +240,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
236240 elt , ce_len , ce -> name );
237241 }
238242
239- if (literal_global )
243+ if (magic & PATHSPEC_LITERAL )
240244 item -> nowildcard_len = item -> len ;
241245 else {
242246 item -> nowildcard_len = simple_length (item -> match );
@@ -402,7 +406,8 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
402406{
403407 struct pathspec ps ;
404408 parse_pathspec (& ps ,
405- PATHSPEC_ALL_MAGIC & ~PATHSPEC_FROMTOP ,
409+ PATHSPEC_ALL_MAGIC &
410+ ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL ),
406411 PATHSPEC_PREFER_CWD ,
407412 prefix , pathspec );
408413 return ps ._raw ;
0 commit comments