summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorDuy Nguyen <pclouds@gmail.com>2015-05-02 09:04:32 +0700
committerJunio C Hamano <gitster@pobox.com>2015-05-03 11:40:13 -0700
commit28fcc0b71a6543fe50576efc1ac8fb4e4555b6a6 (patch)
tree7e1b7636a2b19b02d5097e5279675ca82bb429da /setup.c
parent3d4a3ffe64162b45ae7c991fc60623ecb4678cfd (diff)
downloadgit-28fcc0b71a6543fe50576efc1ac8fb4e4555b6a6.tar.gz
pathspec: avoid the need of "--" when wildcard is used
When "--" is lacking from the command line and a command can take both revs and paths, the idea is if an argument can be seen as both an extended SHA-1 and a path, then "--" is required or git refuses to continue. It's currently implemented as: (1) if an argument is rev, then it must not exist in worktree (2) else, it must exist in worktree (3) else, "--" is required. These rules work for literal paths, but when non-literal pathspec is involved, it almost always requires the user to add "--" because it fails (2) and (1) is really rarely met (take "*.c" for example, (1) is met if there is a ref named "*.c"). This patch modifies the rules a bit by considering any valid (*) wildcard pathspec "exist in worktree". The rules become: (1) if an arg is a rev, then it must either exist in worktree or not be a valid wildcard pathspec. (2) else, it either exists in worktree or is a wildcard pathspec (3) else, "--" is required. With the new rules, "--" is not needed most of the time when wildcard pathspec is involved. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index 979b13f0c6..1055b82708 100644
--- a/setup.c
+++ b/setup.c
@@ -140,7 +140,9 @@ int check_filename(const char *prefix, const char *arg)
if (arg[2] == '\0') /* ":/" is root dir, always exists */
return 1;
name = arg + 2;
- } else if (prefix)
+ } else if (!no_wildcard(arg))
+ return 1;
+ else if (prefix)
name = prefix_filename(prefix, strlen(prefix), arg);
else
name = arg;