Merge branch 'tr/maint-show-walk'

Fixes "git show"'s auto-walking behaviour, and make it behave just
like "git log" does when it walks.

* tr/maint-show-walk:
  show: fix "range implies walking"
  Demonstrate git-show is broken with ranges
This commit is contained in:
Junio C Hamano 2012-07-13 15:36:44 -07:00
commit 5d8d296c1c
2 changed files with 94 additions and 0 deletions

View file

@ -463,6 +463,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)
opt.tweak = show_rev_tweak_rev;
cmd_log_init(argc, argv, prefix, &rev, &opt);
if (!rev.no_walk)
return cmd_log_walk(&rev);
count = rev.pending.nr;
objects = rev.pending.objects;
for (i = 0; i < count && !ret; i++) {

View file

@ -17,4 +17,95 @@ 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_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_done