diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-07-14 10:36:07 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-15 19:56:09 +0200 |
commit | a16bf9dd745a9e43e46d745d850db49358430e46 (patch) | |
tree | 695984bd7293ae822c6e9de91a059b0d6e1c9934 | |
parent | pathspec: support :(literal) syntax for noglob pathspec (diff) | |
download | git-a16bf9dd745a9e43e46d745d850db49358430e46.tar.xz git-a16bf9dd745a9e43e46d745d850db49358430e46.zip |
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: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | Documentation/git.txt | 4 | ||||
-rw-r--r-- | pathspec.c | 2 | ||||
-rwxr-xr-x | t/t6130-pathspec-noglob.sh | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/Documentation/git.txt b/Documentation/git.txt index b738a40e6b..80139ae222 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -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`. diff --git a/pathspec.c b/pathspec.c index 6a16938cb6..b6d8e74277 100644 --- a/pathspec.c +++ b/pathspec.c @@ -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 */ diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh index 49c148e17e..8551b026de 100755 --- a/t/t6130-pathspec-noglob.sh +++ b/t/t6130-pathspec-noglob.sh @@ -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 && |