mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
c8556c6213
When parse_pathspec() is called with no paths, the behavior could be either return no paths, or return one path that is cwd. Some commands do the former, some the latter. parse_pathspec() itself does not make either the default and requires the caller to specify either flag if it may run into this situation. I've grep'd through all parse_pathspec() call sites. Some pass neither, but those are guaranteed never pass empty path to parse_pathspec(). There are two call sites that may pass empty path and are fixed with this patch. [jc: added a test from Antoine's bug report] Reported-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
65 lines
1.3 KiB
Bash
Executable File
65 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='magic pathspec tests using git-log'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit initial &&
|
|
test_tick &&
|
|
git commit --allow-empty -m empty &&
|
|
mkdir sub
|
|
'
|
|
|
|
test_expect_success '"git log :/" should not be ambiguous' '
|
|
git log :/
|
|
'
|
|
|
|
test_expect_success '"git log :/a" should be ambiguous (applied both rev and worktree)' '
|
|
: >a &&
|
|
test_must_fail git log :/a 2>error &&
|
|
grep ambiguous error
|
|
'
|
|
|
|
test_expect_success '"git log :/a -- " should not be ambiguous' '
|
|
git log :/a --
|
|
'
|
|
|
|
test_expect_success '"git log -- :/a" should not be ambiguous' '
|
|
git log -- :/a
|
|
'
|
|
|
|
test_expect_success '"git log :" should be ambiguous' '
|
|
test_must_fail git log : 2>error &&
|
|
grep ambiguous error
|
|
'
|
|
|
|
test_expect_success 'git log -- :' '
|
|
git log -- :
|
|
'
|
|
|
|
test_expect_success 'git log HEAD -- :/' '
|
|
cat >expected <<-EOF &&
|
|
24b24cf initial
|
|
EOF
|
|
(cd sub && git log --oneline HEAD -- :/ >../actual) &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_expect_success 'command line pathspec parsing for "git log"' '
|
|
git reset --hard &&
|
|
>a &&
|
|
git add a &&
|
|
git commit -m "add an empty a" --allow-empty &&
|
|
echo 1 >a &&
|
|
git commit -a -m "update a to 1" &&
|
|
git checkout HEAD^ &&
|
|
echo 2 >a &&
|
|
git commit -a -m "update a to 2" &&
|
|
test_must_fail git merge master &&
|
|
git add a &&
|
|
git log --merge -- a
|
|
'
|
|
|
|
test_done
|