fetch: split out tests for output format
We're about to introduce a new porcelain mode for the output of git-fetch(1). As part of that we'll be introducing a set of new tests that only relate to the output of this command. Split out tests that exercise the output format of git-fetch(1) so that it becomes easier to verify this functionality as a standalone unit. As the tests assume that the default branch is called "main" we set up the corresponding GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME environment variable accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 10, 2023 at 14:34 UTC
2c5691d6cff083ebbd9207d1b518998d448f73f9
2 files changed
+63
-53
t/t5510-fetch.sh
-53
@@ -1118,59 +1118,6 @@ test_expect_success 'fetching with auto-gc does not lock up' '
1118
)
1119
'
1120
1121
-test_expect_success 'fetch aligned output' '
1122
- git clone . full-output &&
1123
- test_commit looooooooooooong-tag &&
1124
- (
1125
- cd full-output &&
1126
- git -c fetch.output=full fetch origin >actual 2>&1 &&
1127
- grep -e "->" actual | cut -c 22- >../actual
1128
- ) &&
1129
- cat >expect <<-\EOF &&
1130
- main -> origin/main
1131
- looooooooooooong-tag -> looooooooooooong-tag
1132
- EOF
1133
- test_cmp expect actual
1134
-'
1135
-
1136
-test_expect_success 'fetch compact output' '
1137
- git clone . compact &&
1138
- test_commit extraaa &&
1139
- (
1140
- cd compact &&
1141
- git -c fetch.output=compact fetch origin >actual 2>&1 &&
1142
- grep -e "->" actual | cut -c 22- >../actual
1143
- ) &&
1144
- cat >expect <<-\EOF &&
1145
- main -> origin/*
1146
- extraaa -> *
1147
- EOF
1148
- test_cmp expect actual
1149
-'
1150
-
1151
-test_expect_success '--no-show-forced-updates' '
1152
- mkdir forced-updates &&
1153
- (
1154
- cd forced-updates &&
1155
- git init &&
1156
- test_commit 1 &&
1157
- test_commit 2
1158
- ) &&
1159
- git clone forced-updates forced-update-clone &&
1160
- git clone forced-updates no-forced-update-clone &&
1161
- git -C forced-updates reset --hard HEAD~1 &&
1162
- (
1163
- cd forced-update-clone &&
1164
- git fetch --show-forced-updates origin 2>output &&
1165
- test_i18ngrep "(forced update)" output
1166
- ) &&
1167
- (
1168
- cd no-forced-update-clone &&
1169
- git fetch --no-show-forced-updates origin 2>output &&
1170
- test_i18ngrep ! "(forced update)" output
1171
- )
1172
-'
1173
-
1121
for section in fetch transfer
1122
do
1123
test_expect_success "$section.hideRefs affects connectivity check" '
t/t5574-fetch-output.sh
new
+63
@@ -0,0 +1,63 @@
1
+#!/bin/sh
2
+
3
+test_description='git fetch output format'
4
+
5
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
+
8
+. ./test-lib.sh
9
+
10
+test_expect_success 'fetch aligned output' '
11
+ git clone . full-output &&
12
+ test_commit looooooooooooong-tag &&
13
+ (
14
+ cd full-output &&
15
+ git -c fetch.output=full fetch origin >actual 2>&1 &&
16
+ grep -e "->" actual | cut -c 22- >../actual
17
+ ) &&
18
+ cat >expect <<-\EOF &&
19
+ main -> origin/main
20
+ looooooooooooong-tag -> looooooooooooong-tag
21
+ EOF
22
+ test_cmp expect actual
23
+'
24
+
25
+test_expect_success 'fetch compact output' '
26
+ git clone . compact &&
27
+ test_commit extraaa &&
28
+ (
29
+ cd compact &&
30
+ git -c fetch.output=compact fetch origin >actual 2>&1 &&
31
+ grep -e "->" actual | cut -c 22- >../actual
32
+ ) &&
33
+ cat >expect <<-\EOF &&
34
+ main -> origin/*
35
+ extraaa -> *
36
+ EOF
37
+ test_cmp expect actual
38
+'
39
+
40
+test_expect_success '--no-show-forced-updates' '
41
+ mkdir forced-updates &&
42
+ (
43
+ cd forced-updates &&
44
+ git init &&
45
+ test_commit 1 &&
46
+ test_commit 2
47
+ ) &&
48
+ git clone forced-updates forced-update-clone &&
49
+ git clone forced-updates no-forced-update-clone &&
50
+ git -C forced-updates reset --hard HEAD~1 &&
51
+ (
52
+ cd forced-update-clone &&
53
+ git fetch --show-forced-updates origin 2>output &&
54
+ test_i18ngrep "(forced update)" output
55
+ ) &&
56
+ (
57
+ cd no-forced-update-clone &&
58
+ git fetch --no-show-forced-updates origin 2>output &&
59
+ test_i18ngrep ! "(forced update)" output
60
+ )
61
+'
62
+
63
+test_done