Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit c6f1b92

Browse files
committed
Merge branch 'nd/literal-pathspecs'
Fixes a regression on 'master' since v1.8.4. * nd/literal-pathspecs: pathspec: stop --*-pathspecs impact on internal parse_pathspec() uses
2 parents 33da0c9 + 4a2d5ae commit c6f1b92

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

builtin/blame.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ static struct origin *find_origin(struct scoreboard *sb,
409409
paths[0] = origin->path;
410410
paths[1] = NULL;
411411

412-
parse_pathspec(&diff_opts.pathspec, PATHSPEC_ALL_MAGIC, 0, "", paths);
412+
parse_pathspec(&diff_opts.pathspec,
413+
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
414+
PATHSPEC_LITERAL_PATH, "", paths);
413415
diff_setup_done(&diff_opts);
414416

415417
if (is_null_sha1(origin->commit->object.sha1))

pathspec.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
128128
die(_("global 'literal' pathspec setting is incompatible "
129129
"with all other global pathspec settings"));
130130

131-
if (elt[0] != ':' || literal_global) {
131+
if (flags & PATHSPEC_LITERAL_PATH)
132+
global_magic = 0;
133+
134+
if (elt[0] != ':' || literal_global ||
135+
(flags & PATHSPEC_LITERAL_PATH)) {
132136
; /* nothing to do */
133137
} else if (elt[1] == '(') {
134138
/* longhand */
@@ -405,6 +409,9 @@ void parse_pathspec(struct pathspec *pathspec,
405409
item[i].magic = prefix_pathspec(item + i, &short_magic,
406410
argv + i, flags,
407411
prefix, prefixlen, entry);
412+
if ((flags & PATHSPEC_LITERAL_PATH) &&
413+
!(magic_mask & PATHSPEC_LITERAL))
414+
item[i].magic |= PATHSPEC_LITERAL;
408415
if (item[i].magic & magic_mask)
409416
unsupported_magic(entry,
410417
item[i].magic & magic_mask,

pathspec.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ struct pathspec {
5858
#define PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE (1<<5)
5959
#define PATHSPEC_PREFIX_ORIGIN (1<<6)
6060
#define PATHSPEC_KEEP_ORDER (1<<7)
61+
/*
62+
* For the callers that just need pure paths from somewhere else, not
63+
* from command line. Global --*-pathspecs options are ignored. No
64+
* magic is parsed in each pathspec either. If PATHSPEC_LITERAL is
65+
* allowed, then it will automatically set for every pathspec.
66+
*/
67+
#define PATHSPEC_LITERAL_PATH (1<<8)
6168

6269
extern void parse_pathspec(struct pathspec *pathspec,
6370
unsigned magic_mask,

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,8 +1372,8 @@ static void prepare_show_merge(struct rev_info *revs)
13721372
i++;
13731373
}
13741374
free_pathspec(&revs->prune_data);
1375-
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC,
1376-
PATHSPEC_PREFER_FULL, "", prune);
1375+
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
1376+
PATHSPEC_PREFER_FULL | PATHSPEC_LITERAL_PATH, "", prune);
13771377
revs->limited = 1;
13781378
}
13791379

t/t6130-pathspec-noglob.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ test_expect_success 'no-glob environment variable works' '
108108
test_cmp expect actual
109109
'
110110

111+
test_expect_success 'blame takes global pathspec flags' '
112+
git --literal-pathspecs blame -- foo &&
113+
git --icase-pathspecs blame -- foo &&
114+
git --glob-pathspecs blame -- foo &&
115+
git --noglob-pathspecs blame -- foo
116+
'
117+
111118
test_expect_success 'setup xxx/bar' '
112119
mkdir xxx &&
113120
test_commit xxx xxx/bar

tree-diff.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
254254
path[0] = p->one->path;
255255
path[1] = NULL;
256256
free_pathspec(&opt->pathspec);
257-
parse_pathspec(&opt->pathspec, PATHSPEC_ALL_MAGIC, 0, "", path);
257+
parse_pathspec(&opt->pathspec,
258+
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
259+
PATHSPEC_LITERAL_PATH, "", path);
258260

259261
/*
260262
* The caller expects us to return a set of vanilla

0 commit comments

Comments
 (0)