git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob f2b9199007752eded932a8da541e1a86e350d10a 5152 bytes (raw)
name: t/t3202-show-branch.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
#!/bin/sh

test_description='test show-branch'

. ./test-lib.sh

# arbitrary reference time: 2009-08-30 19:20:00
GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW

test_expect_success 'setup' '
	test_commit initial &&
	for i in $(test_seq 1 10)
	do
		git checkout -b branch$i initial &&
		test_commit --no-tag branch$i || return 1
	done &&
	git for-each-ref \
		--sort=version:refname \
		--format="%(refname:strip=2)" \
		"refs/heads/branch*" >branches.sorted &&
	sed "s/^> //" >expect <<-\EOF
	> ! [branch1] branch1
	>  ! [branch2] branch2
	>   ! [branch3] branch3
	>    ! [branch4] branch4
	>     ! [branch5] branch5
	>      ! [branch6] branch6
	>       ! [branch7] branch7
	>        ! [branch8] branch8
	>         ! [branch9] branch9
	>          * [branch10] branch10
	> ----------
	>          * [branch10] branch10
	>         +  [branch9] branch9
	>        +   [branch8] branch8
	>       +    [branch7] branch7
	>      +     [branch6] branch6
	>     +      [branch5] branch5
	>    +       [branch4] branch4
	>   +        [branch3] branch3
	>  +         [branch2] branch2
	> +          [branch1] branch1
	> +++++++++* [branch10^] initial
	EOF
'

test_expect_success 'show-branch with more than 8 branches' '
	git show-branch $(cat branches.sorted) >actual &&
	test_cmp expect actual
'

test_expect_success 'show-branch with showbranch.default' '
	for branch in $(cat branches.sorted)
	do
		test_config showbranch.default $branch --add || return 1
	done &&
	git show-branch >actual &&
	test_cmp expect actual
'

test_expect_success 'show-branch --color output' '
	sed "s/^> //" >expect <<-\EOF &&
	> <RED>!<RESET> [branch1] branch1
	>  <GREEN>!<RESET> [branch2] branch2
	>   <YELLOW>!<RESET> [branch3] branch3
	>    <BLUE>!<RESET> [branch4] branch4
	>     <MAGENTA>!<RESET> [branch5] branch5
	>      <CYAN>!<RESET> [branch6] branch6
	>       <BOLD;RED>!<RESET> [branch7] branch7
	>        <BOLD;GREEN>!<RESET> [branch8] branch8
	>         <BOLD;YELLOW>!<RESET> [branch9] branch9
	>          <BOLD;BLUE>*<RESET> [branch10] branch10
	> ----------
	>          <BOLD;BLUE>*<RESET> [branch10] branch10
	>         <BOLD;YELLOW>+<RESET>  [branch9] branch9
	>        <BOLD;GREEN>+<RESET>   [branch8] branch8
	>       <BOLD;RED>+<RESET>    [branch7] branch7
	>      <CYAN>+<RESET>     [branch6] branch6
	>     <MAGENTA>+<RESET>      [branch5] branch5
	>    <BLUE>+<RESET>       [branch4] branch4
	>   <YELLOW>+<RESET>        [branch3] branch3
	>  <GREEN>+<RESET>         [branch2] branch2
	> <RED>+<RESET>          [branch1] branch1
	> <RED>+<RESET><GREEN>+<RESET><YELLOW>+<RESET><BLUE>+<RESET><MAGENTA>+<RESET><CYAN>+<RESET><BOLD;RED>+<RESET><BOLD;GREEN>+<RESET><BOLD;YELLOW>+<RESET><BOLD;BLUE>*<RESET> [branch10^] initial
	EOF
	git show-branch --color=always $(cat branches.sorted) >actual.raw &&
	test_decode_color <actual.raw >actual &&
	test_cmp expect actual
'

test_expect_success 'show branch --remotes' '
	cat >expect.err <<-\EOF &&
	No revs to be shown.
	EOF
	git show-branch -r 2>actual.err >actual.out &&
	test_cmp expect.err actual.err &&
	test_must_be_empty actual.out
'

test_expect_success 'setup show branch --list' '
	sed "s/^> //" >expect <<-\EOF
	>   [branch1] branch1
	>   [branch2] branch2
	>   [branch3] branch3
	>   [branch4] branch4
	>   [branch5] branch5
	>   [branch6] branch6
	>   [branch7] branch7
	>   [branch8] branch8
	>   [branch9] branch9
	> * [branch10] branch10
	EOF
'

test_expect_success 'show branch --list' '
	git show-branch --list $(cat branches.sorted) >actual &&
	test_cmp expect actual
'

test_expect_success 'show branch --list has no --color output' '
	git show-branch --color=always --list $(cat branches.sorted) >actual &&
	test_cmp expect actual
'

test_expect_success 'show branch --merge-base with one argument' '
	for branch in $(cat branches.sorted)
	do
		git rev-parse $branch >expect &&
		git show-branch --merge-base $branch >actual &&
		test_cmp expect actual || return 1
	done
'

test_expect_success 'show branch --merge-base with two arguments' '
	for branch in $(cat branches.sorted)
	do
		git rev-parse initial >expect &&
		git show-branch --merge-base initial $branch >actual &&
		test_cmp expect actual || return 1
	done
'

test_expect_success 'show branch --merge-base with N arguments' '
	git rev-parse initial >expect &&
	git show-branch --merge-base $(cat branches.sorted) >actual &&
	test_cmp expect actual &&

	git merge-base $(cat branches.sorted) >actual &&
	test_cmp expect actual
'

test_expect_success 'show branch --reflog=2' '
	sed "s/^>	//" >expect <<-\EOF &&
	>	! [refs/heads/branch10@{0}] (4 years, 5 months ago) commit: branch10
	>	 ! [refs/heads/branch10@{1}] (4 years, 5 months ago) commit: branch10
	>	--
	>	+  [refs/heads/branch10@{0}] branch10
	>	++ [refs/heads/branch10@{1}] initial
	EOF
	git show-branch --reflog=2 >actual &&
	test_cmp actual expect
'

# incompatible options
while read combo
do
	test_expect_success "show-branch $combo (should fail)" '
		test_must_fail git show-branch $combo 2>error &&
		grep -e "cannot be used together" -e "usage:" error
	'
done <<\EOF
--all --reflog
--merge-base --reflog
--list --merge-base
--reflog --current
EOF

test_done

debug log:

solving f2b9199007 ...
found f2b9199007 in https://80x24.org/mirrors/git.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).