summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-10 21:19:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-10 21:53:21 (GMT)
commitaac4fac1689f7d1414523d2ac96f1c737ee53b71 (patch)
tree86822b59844689a0e63b8c8e46ec7006e014a746 /t
parentdf714f81a709dda9552f137ccd2a3510119298ad (diff)
downloadgit-aac4fac1689f7d1414523d2ac96f1c737ee53b71.zip
git-aac4fac1689f7d1414523d2ac96f1c737ee53b71.tar.gz
git-aac4fac1689f7d1414523d2ac96f1c737ee53b71.tar.bz2
get_sha1: don't die() on bogus search strings
The get_sha1() function generally returns an error code rather than dying, and we sometimes speculatively call it with something that may be a revision or a pathspec, in order to see which one it might be. If it sees a bogus ":/" search string, though, it complains, without giving the caller the opportunity to recover. We can demonstrate this in t6133 by looking for ":/*.t", which should mean "*.t at the root of the tree", but instead dies because of the invalid regex (the "*" has nothing to operate on). We can fix this by returning an error rather than calling die(). Unfortunately, the tradeoff is that the error message is slightly worse in cases where we _do_ know we have a rev. E.g., running "git log ':/*.t' --" before yielded: fatal: Invalid search pattern: *.t and now we get only: fatal: bad revision ':/*.t' There's not a simple way to fix this short of passing a "quiet" flag all the way through the get_sha1() stack. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t6133-pathspec-rev-dwim.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t6133-pathspec-rev-dwim.sh b/t/t6133-pathspec-rev-dwim.sh
index 8e5b338..a290ffc 100755
--- a/t/t6133-pathspec-rev-dwim.sh
+++ b/t/t6133-pathspec-rev-dwim.sh
@@ -35,4 +35,14 @@ test_expect_success '@{foo} with metacharacters dwims to rev' '
test_cmp expect actual
'
+test_expect_success ':/*.t from a subdir dwims to a pathspec' '
+ mkdir subdir &&
+ (
+ cd subdir &&
+ git log -- ":/*.t" >expect &&
+ git log ":/*.t" >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done