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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2013-07-14 15:36:07 +07:00 коммит произвёл Junio C Hamano
Родитель 5c6933d201
Коммит a16bf9dd74
3 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -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 &&