mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
aac4fac168
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>
48 lines
1.1 KiB
Bash
Executable file
48 lines
1.1 KiB
Bash
Executable file
#!/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_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
|