Skip to content

Commit a91251d

Browse files
committed
Merge branch 'test-cmp-refs-git-dir'
2 parents daeed0d + 367c28f commit a91251d

31 files changed

+73
-68
lines changed

t/t5411/common-functions.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,20 @@ format_and_save_expect () {
5959

6060
test_cmp_refs () {
6161
indir=
62+
gitdir=
6263
if test "$1" = "-C"
6364
then
6465
shift
6566
indir="$1"
6667
shift
68+
elif test "$1" = "--git-dir"
69+
then
70+
shift
71+
gitdir="$1"
72+
shift
6773
fi
68-
indir=${indir:+"$indir"/}
6974
cat >show-ref.expect &&
70-
git ${indir:+ -C "$indir"} show-ref >show-ref.pristine &&
75+
git ${indir:+ -C "$indir"} ${gitdir:+ --git-dir="$gitdir"} show-ref >show-ref.pristine &&
7176
make_user_friendly_and_stable_output <show-ref.pristine >show-ref.filtered &&
7277
test_cmp show-ref.expect show-ref.filtered
7378
}

t/t5411/once-0010-report-status-v1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test_expect_success "proc-receive: report status v1" '
8383
EOF
8484
test_cmp expect actual &&
8585
86-
test_cmp_refs -C "$upstream" <<-EOF
86+
test_cmp_refs --git-dir "$upstream" <<-EOF
8787
<COMMIT-A> refs/for/main/topic1
8888
<COMMIT-A> refs/heads/foo
8989
<COMMIT-B> refs/heads/main

t/t5411/test-0000-standard-git-push.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_expect_success "git-push ($PROTOCOL)" '
2020
EOF
2121
test_cmp expect actual &&
2222
23-
test_cmp_refs -C "$upstream" <<-EOF
23+
test_cmp_refs --git-dir "$upstream" <<-EOF
2424
<COMMIT-B> refs/heads/main
2525
<COMMIT-A> refs/heads/next
2626
EOF
@@ -45,7 +45,7 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
4545
EOF
4646
test_cmp expect actual &&
4747
48-
test_cmp_refs -C "$upstream" <<-EOF
48+
test_cmp_refs --git-dir "$upstream" <<-EOF
4949
<COMMIT-B> refs/heads/main
5050
<COMMIT-A> refs/heads/next
5151
EOF
@@ -74,7 +74,7 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" '
7474
EOF
7575
test_cmp expect actual &&
7676
77-
test_cmp_refs -C "$upstream" <<-EOF
77+
test_cmp_refs --git-dir "$upstream" <<-EOF
7878
<COMMIT-B> refs/heads/main
7979
<COMMIT-B> refs/heads/next
8080
EOF
@@ -114,7 +114,7 @@ test_expect_success "git-push -f ($PROTOCOL)" '
114114
EOF
115115
test_cmp expect actual &&
116116
117-
test_cmp_refs -C "$upstream" <<-EOF
117+
test_cmp_refs --git-dir "$upstream" <<-EOF
118118
<COMMIT-A> refs/heads/a/b/c
119119
<COMMIT-A> refs/heads/main
120120
<COMMIT-A> refs/review/main/topic

t/t5411/test-0001-standard-git-push--porcelain.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" '
2121
EOF
2222
test_cmp expect actual &&
2323
24-
test_cmp_refs -C "$upstream" <<-EOF
24+
test_cmp_refs --git-dir "$upstream" <<-EOF
2525
<COMMIT-B> refs/heads/main
2626
<COMMIT-A> refs/heads/next
2727
EOF
@@ -47,7 +47,7 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
4747
EOF
4848
test_cmp expect actual &&
4949
50-
test_cmp_refs -C "$upstream" <<-EOF
50+
test_cmp_refs --git-dir "$upstream" <<-EOF
5151
<COMMIT-B> refs/heads/main
5252
<COMMIT-A> refs/heads/next
5353
EOF
@@ -77,7 +77,7 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" '
7777
EOF
7878
test_cmp expect actual &&
7979
80-
test_cmp_refs -C "$upstream" <<-EOF
80+
test_cmp_refs --git-dir "$upstream" <<-EOF
8181
<COMMIT-B> refs/heads/main
8282
<COMMIT-B> refs/heads/next
8383
EOF
@@ -118,7 +118,7 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" '
118118
EOF
119119
test_cmp expect actual &&
120120
121-
test_cmp_refs -C "$upstream" <<-EOF
121+
test_cmp_refs --git-dir "$upstream" <<-EOF
122122
<COMMIT-A> refs/heads/a/b/c
123123
<COMMIT-A> refs/heads/main
124124
<COMMIT-A> refs/review/main/topic

t/t5411/test-0002-pre-receive-declined.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success "git-push is declined ($PROTOCOL)" '
2121
EOF
2222
test_cmp expect actual &&
2323
24-
test_cmp_refs -C "$upstream" <<-\EOF
24+
test_cmp_refs --git-dir "$upstream" <<-\EOF
2525
<COMMIT-A> refs/heads/main
2626
EOF
2727
'

t/t5411/test-0003-pre-receive-declined--porcelain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" '
2222
EOF
2323
test_cmp expect actual &&
2424
25-
test_cmp_refs -C "$upstream" <<-EOF
25+
test_cmp_refs --git-dir "$upstream" <<-EOF
2626
<COMMIT-A> refs/heads/main
2727
EOF
2828
'

t/t5411/test-0011-no-hook-error.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL)
2020
EOF
2121
test_cmp expect actual &&
2222
23-
test_cmp_refs -C "$upstream" <<-EOF
23+
test_cmp_refs --git-dir "$upstream" <<-EOF
2424
<COMMIT-A> refs/heads/main
2525
<COMMIT-A> refs/heads/next
2626
EOF
@@ -54,7 +54,7 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO
5454
EOF
5555
test_cmp expect actual &&
5656
57-
test_cmp_refs -C "$upstream" <<-EOF
57+
test_cmp_refs --git-dir "$upstream" <<-EOF
5858
<COMMIT-A> refs/heads/main
5959
EOF
6060
'

t/t5411/test-0012-no-hook-error--porcelain.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/
2121
EOF
2222
test_cmp expect actual &&
2323
24-
test_cmp_refs -C "$upstream" <<-EOF
24+
test_cmp_refs --git-dir "$upstream" <<-EOF
2525
<COMMIT-A> refs/heads/main
2626
<COMMIT-A> refs/heads/next
2727
EOF
@@ -56,7 +56,7 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO
5656
EOF
5757
test_cmp expect actual &&
5858
59-
test_cmp_refs -C "$upstream" <<-EOF
59+
test_cmp_refs --git-dir "$upstream" <<-EOF
6060
<COMMIT-A> refs/heads/main
6161
EOF
6262
'

t/t5411/test-0013-bad-protocol.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" '
3434
EOF
3535
test_cmp expect actual-error &&
3636
37-
test_cmp_refs -C "$upstream" <<-EOF
37+
test_cmp_refs --git-dir "$upstream" <<-EOF
3838
<COMMIT-A> refs/heads/main
3939
EOF
4040
'
@@ -65,7 +65,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
6565
grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
6666
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
6767
68-
test_cmp_refs -C "$upstream" <<-\EOF
68+
test_cmp_refs --git-dir "$upstream" <<-\EOF
6969
<COMMIT-A> refs/heads/main
7070
EOF
7171
'
@@ -96,7 +96,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
9696
grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
9797
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
9898
99-
test_cmp_refs -C "$upstream" <<-EOF
99+
test_cmp_refs --git-dir "$upstream" <<-EOF
100100
<COMMIT-A> refs/heads/main
101101
EOF
102102
'
@@ -126,7 +126,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
126126
test_cmp expect actual &&
127127
grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
128128
129-
test_cmp_refs -C "$upstream" <<-EOF
129+
test_cmp_refs --git-dir "$upstream" <<-EOF
130130
<COMMIT-A> refs/heads/main
131131
EOF
132132
'
@@ -158,7 +158,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
158158
test_cmp expect actual &&
159159
grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
160160
161-
test_cmp_refs -C "$upstream" <<-EOF
161+
test_cmp_refs --git-dir "$upstream" <<-EOF
162162
<COMMIT-A> refs/heads/main
163163
EOF
164164
'
@@ -188,7 +188,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
188188
test_cmp expect actual &&
189189
grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
190190
191-
test_cmp_refs -C "$upstream" <<-EOF
191+
test_cmp_refs --git-dir "$upstream" <<-EOF
192192
<COMMIT-A> refs/heads/main
193193
EOF
194194
'
@@ -222,7 +222,7 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" '
222222
EOF
223223
test_cmp expect actual &&
224224
225-
test_cmp_refs -C "$upstream" <<-EOF
225+
test_cmp_refs --git-dir "$upstream" <<-EOF
226226
<COMMIT-A> refs/heads/main
227227
<COMMIT-A> refs/heads/next
228228
EOF
@@ -263,7 +263,7 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" '
263263
EOF
264264
test_cmp expect actual &&
265265
266-
test_cmp_refs -C "$upstream" <<-EOF
266+
test_cmp_refs --git-dir "$upstream" <<-EOF
267267
<COMMIT-A> refs/heads/main
268268
EOF
269269
'
@@ -296,7 +296,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" '
296296
EOF
297297
test_cmp expect actual &&
298298
299-
test_cmp_refs -C "$upstream" <<-EOF
299+
test_cmp_refs --git-dir "$upstream" <<-EOF
300300
<COMMIT-A> refs/heads/main
301301
EOF
302302
'

t/t5411/test-0014-bad-protocol--porcelain.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc
3434
EOF
3535
test_cmp expect actual-error &&
3636
37-
test_cmp_refs -C "$upstream" <<-EOF
37+
test_cmp_refs --git-dir "$upstream" <<-EOF
3838
<COMMIT-A> refs/heads/main
3939
EOF
4040
'
@@ -65,7 +65,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
6565
grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
6666
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
6767
68-
test_cmp_refs -C "$upstream" <<-EOF
68+
test_cmp_refs --git-dir "$upstream" <<-EOF
6969
<COMMIT-A> refs/heads/main
7070
EOF
7171
'
@@ -96,7 +96,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
9696
grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
9797
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
9898
99-
test_cmp_refs -C "$upstream" <<-EOF
99+
test_cmp_refs --git-dir "$upstream" <<-EOF
100100
<COMMIT-A> refs/heads/main
101101
EOF
102102
'
@@ -126,7 +126,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
126126
test_cmp expect actual &&
127127
grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
128128
129-
test_cmp_refs -C "$upstream" <<-EOF
129+
test_cmp_refs --git-dir "$upstream" <<-EOF
130130
<COMMIT-A> refs/heads/main
131131
EOF
132132
'
@@ -158,7 +158,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
158158
test_cmp expect actual &&
159159
grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
160160
161-
test_cmp_refs -C "$upstream" <<-EOF
161+
test_cmp_refs --git-dir "$upstream" <<-EOF
162162
<COMMIT-A> refs/heads/main
163163
EOF
164164
'
@@ -188,7 +188,7 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
188188
test_cmp expect actual &&
189189
grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
190190
191-
test_cmp_refs -C "$upstream" <<-EOF
191+
test_cmp_refs --git-dir "$upstream" <<-EOF
192192
<COMMIT-A> refs/heads/main
193193
EOF
194194
'
@@ -223,7 +223,7 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)
223223
EOF
224224
test_cmp expect actual &&
225225
226-
test_cmp_refs -C "$upstream" <<-EOF
226+
test_cmp_refs --git-dir "$upstream" <<-EOF
227227
<COMMIT-A> refs/heads/main
228228
<COMMIT-A> refs/heads/next
229229
EOF
@@ -264,7 +264,7 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
264264
EOF
265265
test_cmp expect actual &&
266266
267-
test_cmp_refs -C "$upstream" <<-EOF
267+
test_cmp_refs --git-dir "$upstream" <<-EOF
268268
<COMMIT-A> refs/heads/main
269269
EOF
270270
'
@@ -298,7 +298,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce
298298
EOF
299299
test_cmp expect actual &&
300300
301-
test_cmp_refs -C "$upstream" <<-EOF
301+
test_cmp_refs --git-dir "$upstream" <<-EOF
302302
<COMMIT-A> refs/heads/main
303303
EOF
304304
'

0 commit comments

Comments
 (0)