summaryrefslogtreecommitdiffstats
path: root/tree-diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-10-26 09:09:20 +0700
committerJunio C Hamano <gitster@pobox.com>2013-10-28 09:57:36 -0700
commit4a2d5ae262a6d372d0951da9cee3c7ad2a8dbca6 (patch)
tree39fdf613b7433228f10a0ac613b3cfd9e14a760b /tree-diff.c
parent3d092bfc6f2d9a998967979f926c661e9762601c (diff)
downloadgit-4a2d5ae262a6d372d0951da9cee3c7ad2a8dbca6.tar.gz
git-4a2d5ae262a6d372d0951da9cee3c7ad2a8dbca6.tar.xz
pathspec: stop --*-pathspecs impact on internal parse_pathspec() uses
Normally parse_pathspec() is used on command line arguments where it can do fancy thing like parsing magic on each argument or adding magic for all pathspecs based on --*-pathspecs options. There's another use of parse_pathspec(), where pathspec is needed, but the input is known to be pure paths. In this case we usually don't want --*-pathspecs to interfere. And we definitely do not want to parse magic in these paths, regardless of --literal-pathspecs. Add new flag PATHSPEC_LITERAL_PATH for this purpose. When it's set, --*-pathspecs are ignored, no magic is parsed. And if the caller allows PATHSPEC_LITERAL (i.e. the next calls can take literal magic), then PATHSPEC_LITERAL will be set. This fixes cases where git chokes when GIT_*_PATHSPECS are set because parse_pathspec() indicates it won't take any magic. But GIT_*_PATHSPECS add them anyway. These are export GIT_LITERAL_PATHSPECS=1 git blame -- something git log --follow something git log --merge "git ls-files --with-tree=path" (aka parse_pathspec() in overlay_tree_on_cache()) is safe because the input is empty, and producing one pathspec due to PATHSPEC_PREFER_CWD does not take any magic into account. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree-diff.c')
-rw-r--r--tree-diff.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tree-diff.c b/tree-diff.c
index ccf9d7c8f..456660c7a 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -254,7 +254,9 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
path[0] = p->one->path;
path[1] = NULL;
free_pathspec(&opt->pathspec);
- parse_pathspec(&opt->pathspec, PATHSPEC_ALL_MAGIC, 0, "", path);
+ parse_pathspec(&opt->pathspec,
+ PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
+ PATHSPEC_LITERAL_PATH, "", path);
/*
* The caller expects us to return a set of vanilla