Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 builtin/list-files.c  | 1 +
 pathspec.c            | 4 ++++
 pathspec.h            | 1 +
 t/t7013-list-files.sh | 7 ++++++-
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/builtin/list-files.c b/builtin/list-files.c
index fc9c8d4..c85bb55 100644
--- a/builtin/list-files.c
+++ b/builtin/list-files.c
@@ -557,6 +557,7 @@ int cmd_list_files(int argc, const char **argv, const char 
*cmd_prefix)
        parse_pathspec(&pathspec, 0,
                       PATHSPEC_PREFER_CWD |
                       (max_depth != -1 ? PATHSPEC_MAXDEPTH_VALID : 0) |
+                      PATHSPEC_DEFAULT_GLOB |
                       PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
                       cmd_prefix, argv);
        pathspec.max_depth = max_depth;
diff --git a/pathspec.c b/pathspec.c
index 5573127..3770c26 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -396,6 +396,10 @@ void parse_pathspec(struct pathspec *pathspec,
        global.glob    = git_env_bool(GIT_GLOB_PATHSPECS_ENVIRONMENT,    0) != 
0;
        global.noglob  = git_env_bool(GIT_NOGLOB_PATHSPECS_ENVIRONMENT,  0) != 
0;
        global.icase   = git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT,   0) != 
0;
+       if ((flags & PATHSPEC_DEFAULT_GLOB) &&
+           !getenv(GIT_GLOB_PATHSPECS_ENVIRONMENT) &&
+           !getenv(GIT_NOGLOB_PATHSPECS_ENVIRONMENT))
+               global.glob = 1;
        if (global.glob && global.noglob)
                die(_("global 'glob' and 'noglob' pathspec settings are 
incompatible"));
 
diff --git a/pathspec.h b/pathspec.h
index 0c11262..7e4058f 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -67,6 +67,7 @@ struct pathspec {
  * allowed, then it will automatically set for every pathspec.
  */
 #define PATHSPEC_LITERAL_PATH (1<<8)
+#define PATHSPEC_DEFAULT_GLOB (1<<9) /* :(glob) by default */
 
 extern void parse_pathspec(struct pathspec *pathspec,
                           unsigned magic_mask,
diff --git a/t/t7013-list-files.sh b/t/t7013-list-files.sh
index 392cce1..4a9368e 100755
--- a/t/t7013-list-files.sh
+++ b/t/t7013-list-files.sh
@@ -116,11 +116,16 @@ test_expect_success 'column output' '
 '
 
 test_expect_success 'list-files selectively from index' '
-       git list-files -R "*a" >actual &&
+       git list-files -R "**/a" >actual &&
        cat >expect <<-\EOF &&
        a
        sa/a
        EOF
+       test_cmp expect actual &&
+       git list-files -R "*a" >actual &&
+       cat >expect <<-\EOF &&
+       a
+       EOF
        test_cmp expect actual
 '
 
-- 
2.3.0.rc1.137.g477eb31

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to