summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/checkout.c3
-rw-r--r--setup.c6
-rwxr-xr-xt/t2019-checkout-ambiguous-ref.sh26
-rwxr-xr-xt/t6133-pathspec-rev-dwim.sh38
4 files changed, 42 insertions, 31 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index d34f58e..e5c16af 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -965,7 +965,8 @@ static int parse_branchname_arg(int argc, const char **argv,
*/
int recover_with_dwim = dwim_new_local_branch_ok;
- if (!has_dash_dash && check_filename(NULL, arg))
+ if (!has_dash_dash &&
+ (check_filename(NULL, arg) || !no_wildcard(arg)))
recover_with_dwim = 0;
/*
* Accept "git checkout foo" and "git checkout foo --"
diff --git a/setup.c b/setup.c
index 1055b82..69a8ada 100644
--- a/setup.c
+++ b/setup.c
@@ -140,9 +140,7 @@ 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 (!no_wildcard(arg))
- return 1;
- else if (prefix)
+ } else if (prefix)
name = prefix_filename(prefix, strlen(prefix), arg);
else
name = arg;
@@ -203,7 +201,7 @@ void verify_filename(const char *prefix,
{
if (*arg == '-')
die("bad flag '%s' used after filename", arg);
- if (check_filename(prefix, arg))
+ if (check_filename(prefix, arg) || !no_wildcard(arg))
return;
die_verify_filename(prefix, arg, diagnose_misspelt_rev);
}
diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh
index 199b22d..b99d519 100755
--- a/t/t2019-checkout-ambiguous-ref.sh
+++ b/t/t2019-checkout-ambiguous-ref.sh
@@ -56,30 +56,4 @@ test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
test_i18ngrep ! "^HEAD is now at" stderr
'
-test_expect_success 'wildcard ambiguation, paths win' '
- git init ambi &&
- (
- cd ambi &&
- echo a >a.c &&
- git add a.c &&
- echo b >a.c &&
- git checkout "*.c" &&
- echo a >expect &&
- test_cmp expect a.c
- )
-'
-
-test_expect_success !MINGW 'wildcard ambiguation, refs lose' '
- git init ambi2 &&
- (
- cd ambi2 &&
- echo a >"*.c" &&
- git add . &&
- test_must_fail git show :"*.c" &&
- git show :"*.c" -- >actual &&
- echo a >expect &&
- test_cmp expect actual
- )
-'
-
test_done
diff --git a/t/t6133-pathspec-rev-dwim.sh b/t/t6133-pathspec-rev-dwim.sh
new file mode 100755
index 0000000..8e5b338
--- /dev/null
+++ b/t/t6133-pathspec-rev-dwim.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='test dwim of revs versus pathspecs in revision parser'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit base &&
+ echo content >"br[ack]ets" &&
+ git add . &&
+ test_tick &&
+ git commit -m brackets
+'
+
+test_expect_success 'non-rev wildcard dwims to pathspec' '
+ git log -- "*.t" >expect &&
+ git log "*.t" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'tree:path with metacharacters dwims to rev' '
+ git show "HEAD:br[ack]ets" -- >expect &&
+ git show "HEAD:br[ack]ets" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '^{foo} with metacharacters dwims to rev' '
+ git log "HEAD^{/b.*}" -- >expect &&
+ git log "HEAD^{/b.*}" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '@{foo} with metacharacters dwims to rev' '
+ git log "HEAD@{now [or thereabouts]}" -- >expect &&
+ git log "HEAD@{now [or thereabouts]}" >actual &&
+ test_cmp expect actual
+'
+
+test_done