|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='Verify git refs list functionality and compatibility with git show-ref' |
| 4 | +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 5 | +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | + |
| 7 | +. ./test-lib.sh |
| 8 | + |
| 9 | +test_expect_success setup ' |
| 10 | + test_commit --annotate A && |
| 11 | + git checkout -b side && |
| 12 | + test_commit --annotate B && |
| 13 | + git checkout main && |
| 14 | + test_commit C && |
| 15 | + git branch B A^0 |
| 16 | +' |
| 17 | + |
| 18 | +test_expect_success 'refs list --branches, --tags, --head, pattern' ' |
| 19 | + for branch in B main side |
| 20 | + do |
| 21 | + echo $(git rev-parse refs/heads/$branch) refs/heads/$branch || return 1 |
| 22 | + done >expect.branches && |
| 23 | + git refs list --branches >actual && |
| 24 | + test_cmp expect.branches actual && |
| 25 | +
|
| 26 | + for tag in A B C |
| 27 | + do |
| 28 | + echo $(git rev-parse refs/tags/$tag) refs/tags/$tag || return 1 |
| 29 | + done >expect.tags && |
| 30 | + git refs list --tags >actual && |
| 31 | + test_cmp expect.tags actual && |
| 32 | +
|
| 33 | + cat expect.branches expect.tags >expect && |
| 34 | + git refs list --branches --tags >actual && |
| 35 | + test_cmp expect actual && |
| 36 | +
|
| 37 | + { |
| 38 | + echo $(git rev-parse HEAD) HEAD && |
| 39 | + cat expect.branches expect.tags |
| 40 | + } >expect && |
| 41 | + git refs list --branches --tags --head >actual && |
| 42 | + test_cmp expect actual && |
| 43 | +
|
| 44 | + { |
| 45 | + echo $(git rev-parse HEAD) HEAD && |
| 46 | + echo $(git rev-parse refs/heads/B) refs/heads/B && |
| 47 | + echo $(git rev-parse refs/tags/B) refs/tags/B |
| 48 | + } >expect && |
| 49 | + git refs list --head B >actual && |
| 50 | + test_cmp expect actual && |
| 51 | +
|
| 52 | + { |
| 53 | + echo $(git rev-parse refs/heads/B) refs/heads/B && |
| 54 | + echo $(git rev-parse refs/tags/A) refs/tags/A && |
| 55 | + echo $(git rev-parse refs/tags/B) refs/tags/B |
| 56 | + } >expect && |
| 57 | + git refs list A B >actual && |
| 58 | + test_cmp expect actual |
| 59 | +' |
| 60 | + |
| 61 | +test_expect_success 'Backward compatibility with show-ref' ' |
| 62 | + git show-ref >expect&& |
| 63 | + git refs list >actual&& |
| 64 | + test_cmp expect actual && |
| 65 | +
|
| 66 | + git show-ref --branches >expect && |
| 67 | + git refs list --branches >actual && |
| 68 | + test_cmp expect actual && |
| 69 | +
|
| 70 | + git show-ref --tags >expect && |
| 71 | + git refs list --tags >actual && |
| 72 | + test_cmp expect actual && |
| 73 | +
|
| 74 | + git show-ref --head >expect && |
| 75 | + git refs list --head >actual && |
| 76 | + test_cmp expect actual && |
| 77 | +
|
| 78 | + git show-ref --branches --tags --head >expect && |
| 79 | + git refs list --branches --tags --head >actual && |
| 80 | + test_cmp expect actual && |
| 81 | +
|
| 82 | + git show-ref B >expect && |
| 83 | + git refs list B >actual && |
| 84 | + test_cmp expect actual && |
| 85 | +
|
| 86 | + git show-ref --head B >expect && |
| 87 | + git refs list --head B >actual && |
| 88 | + test_cmp expect actual && |
| 89 | +
|
| 90 | + git show-ref A B >expect && |
| 91 | + git refs list A B >actual && |
| 92 | + test_cmp expect actual |
| 93 | +' |
| 94 | + |
| 95 | +test_done |
0 commit comments