mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
695985f483
Because "--graph" is about connected history while --no-walk is about discrete points, it does not make sense to allow these two options at the same time. [1] This change makes a few calls to "show --graph" fail in t4052, but asking to show one commit with graph is a nonsensical thing to do. Thus, tests on "show --graph" in t4052 have been removed [2,3]. Same tests on "show" without --graph option have already been tested in 4052. 3 testcases have been added to test this patch. [1]: http://article.gmane.org/gmane.comp.version-control.git/216083 [2]: http://article.gmane.org/gmane.comp.version-control.git/264950 [3]: http://article.gmane.org/gmane.comp.version-control.git/265107 Helped-By: Eric Sunshine <sunshine@sunshineco.com> Helped-By: René Scharfe <l.s.r@web.de> Helped-By: Junio C Hamano <gitster@pobox.com> Signed-off-by: Dongcan Jiang <dongcan.jiang@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
132 lines
3.1 KiB
Bash
Executable File
132 lines
3.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git show'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
echo hello world >foo &&
|
|
H=$(git hash-object -w foo) &&
|
|
git tag -a foo-tag -m "Tags $H" $H &&
|
|
HH=$(expr "$H" : "\(..\)") &&
|
|
H38=$(expr "$H" : "..\(.*\)") &&
|
|
rm -f .git/objects/$HH/$H38
|
|
'
|
|
|
|
test_expect_success 'showing a tag that point at a missing object' '
|
|
test_must_fail git --no-pager show foo-tag
|
|
'
|
|
|
|
test_expect_success 'set up a bit of history' '
|
|
test_commit main1 &&
|
|
test_commit main2 &&
|
|
test_commit main3 &&
|
|
git tag -m "annotated tag" annotated &&
|
|
git checkout -b side HEAD^^ &&
|
|
test_commit side2 &&
|
|
test_commit side3 &&
|
|
test_merge merge main3
|
|
'
|
|
|
|
test_expect_success 'showing two commits' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main2)
|
|
commit $(git rev-parse main3)
|
|
EOF
|
|
git show main2 main3 >actual &&
|
|
grep ^commit actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing a range walks (linear)' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main3)
|
|
commit $(git rev-parse main2)
|
|
EOF
|
|
git show main1..main3 >actual &&
|
|
grep ^commit actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing a range walks (Y shape, ^ first)' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main3)
|
|
commit $(git rev-parse main2)
|
|
EOF
|
|
git show ^side3 main3 >actual &&
|
|
grep ^commit actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing a range walks (Y shape, ^ last)' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main3)
|
|
commit $(git rev-parse main2)
|
|
EOF
|
|
git show main3 ^side3 >actual &&
|
|
grep ^commit actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing with -N walks' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main3)
|
|
commit $(git rev-parse main2)
|
|
EOF
|
|
git show -2 main3 >actual &&
|
|
grep ^commit actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing annotated tag' '
|
|
cat >expect <<-EOF &&
|
|
tag annotated
|
|
commit $(git rev-parse annotated^{commit})
|
|
EOF
|
|
git show annotated >actual &&
|
|
grep -E "^(commit|tag)" actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing annotated tag plus commit' '
|
|
cat >expect <<-EOF &&
|
|
tag annotated
|
|
commit $(git rev-parse annotated^{commit})
|
|
commit $(git rev-parse side3)
|
|
EOF
|
|
git show annotated side3 >actual &&
|
|
grep -E "^(commit|tag)" actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success 'showing range' '
|
|
cat >expect <<-EOF &&
|
|
commit $(git rev-parse main3)
|
|
commit $(git rev-parse main2)
|
|
EOF
|
|
git show ^side3 annotated >actual &&
|
|
grep -E "^(commit|tag)" actual >actual.filtered &&
|
|
test_cmp expect actual.filtered
|
|
'
|
|
|
|
test_expect_success '-s suppresses diff' '
|
|
cat >expect <<-\EOF &&
|
|
merge
|
|
main3
|
|
EOF
|
|
git show -s --format=%s merge main3 >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success '--quiet suppresses diff' '
|
|
echo main3 >expect &&
|
|
git show --quiet --format=%s main3 >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'show --graph is forbidden' '
|
|
test_must_fail git show --graph HEAD
|
|
'
|
|
|
|
test_done
|