Commit a16bf9dd authored by Duy Nguyen's avatar Duy Nguyen Committed by Junio C Hamano

pathspec: make --literal-pathspecs disable pathspec magic

--literal-pathspecs and its equivalent environment variable are
probably used for scripting. In that setting, pathspec magic may be
unwanted. Disabling globbing in individual pathspec can be done via
:(literal) magic.
Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 5c6933d2
......@@ -450,8 +450,8 @@ help ...`.
linkgit:git-replace[1] for more information.
--literal-pathspecs::
Treat pathspecs literally, rather than as glob patterns. This is
equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
Treat pathspecs literally (i.e. no globbing, no pathspec magic).
This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
variable to `1`.
......
......@@ -103,7 +103,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
if (literal_global)
global_magic |= PATHSPEC_LITERAL;
if (elt[0] != ':') {
if (elt[0] != ':' || literal_global) {
; /* nothing to do */
} else if (elt[1] == '(') {
/* longhand */
......
......@@ -77,6 +77,12 @@ test_expect_success 'no-glob option matches literally (bracket)' '
test_cmp expect actual
'
test_expect_success 'no-glob option disables :(literal)' '
: >expect &&
git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
test_cmp expect actual
'
test_expect_success 'no-glob environment variable works' '
echo star >expect &&
GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment