t6050-replace: modernize test format

Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Cai committed May 18, 2023 at 20:03 UTC 32942346aa1b2010640503309dae276072c84f6a
1 file changed +148 -148
t/t6050-replace.sh
+148 -148
@@ -62,59 +62,59 @@ HASH6=
62 HASH7=
63
64 test_expect_success 'set up buggy branch' '
65 - echo "line 1" >>hello &&
66 - echo "line 2" >>hello &&
67 - echo "line 3" >>hello &&
68 - echo "line 4" >>hello &&
69 - add_and_commit_file hello "4 lines" &&
70 - HASH1=$(git rev-parse --verify HEAD) &&
71 - echo "line BUG" >>hello &&
72 - echo "line 6" >>hello &&
73 - echo "line 7" >>hello &&
74 - echo "line 8" >>hello &&
75 - add_and_commit_file hello "4 more lines with a BUG" &&
76 - HASH2=$(git rev-parse --verify HEAD) &&
77 - echo "line 9" >>hello &&
78 - echo "line 10" >>hello &&
79 - add_and_commit_file hello "2 more lines" &&
80 - HASH3=$(git rev-parse --verify HEAD) &&
81 - echo "line 11" >>hello &&
82 - add_and_commit_file hello "1 more line" &&
83 - HASH4=$(git rev-parse --verify HEAD) &&
84 - sed -e "s/BUG/5/" hello >hello.new &&
85 - mv hello.new hello &&
86 - add_and_commit_file hello "BUG fixed" &&
87 - HASH5=$(git rev-parse --verify HEAD) &&
88 - echo "line 12" >>hello &&
89 - echo "line 13" >>hello &&
90 - add_and_commit_file hello "2 more lines" &&
91 - HASH6=$(git rev-parse --verify HEAD) &&
92 - echo "line 14" >>hello &&
93 - echo "line 15" >>hello &&
94 - echo "line 16" >>hello &&
95 - add_and_commit_file hello "again 3 more lines" &&
96 - HASH7=$(git rev-parse --verify HEAD)
65 + echo "line 1" >>hello &&
66 + echo "line 2" >>hello &&
67 + echo "line 3" >>hello &&
68 + echo "line 4" >>hello &&
69 + add_and_commit_file hello "4 lines" &&
70 + HASH1=$(git rev-parse --verify HEAD) &&
71 + echo "line BUG" >>hello &&
72 + echo "line 6" >>hello &&
73 + echo "line 7" >>hello &&
74 + echo "line 8" >>hello &&
75 + add_and_commit_file hello "4 more lines with a BUG" &&
76 + HASH2=$(git rev-parse --verify HEAD) &&
77 + echo "line 9" >>hello &&
78 + echo "line 10" >>hello &&
79 + add_and_commit_file hello "2 more lines" &&
80 + HASH3=$(git rev-parse --verify HEAD) &&
81 + echo "line 11" >>hello &&
82 + add_and_commit_file hello "1 more line" &&
83 + HASH4=$(git rev-parse --verify HEAD) &&
84 + sed -e "s/BUG/5/" hello >hello.new &&
85 + mv hello.new hello &&
86 + add_and_commit_file hello "BUG fixed" &&
87 + HASH5=$(git rev-parse --verify HEAD) &&
88 + echo "line 12" >>hello &&
89 + echo "line 13" >>hello &&
90 + add_and_commit_file hello "2 more lines" &&
91 + HASH6=$(git rev-parse --verify HEAD) &&
92 + echo "line 14" >>hello &&
93 + echo "line 15" >>hello &&
94 + echo "line 16" >>hello &&
95 + add_and_commit_file hello "again 3 more lines" &&
96 + HASH7=$(git rev-parse --verify HEAD)
97 '
98
99 test_expect_success 'replace the author' '
100 - git cat-file commit $HASH2 | grep "author A U Thor" &&
101 - R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
102 - git cat-file commit $R | grep "author O Thor" &&
103 - git update-ref refs/replace/$HASH2 $R &&
104 - git show HEAD~5 | grep "O Thor" &&
105 - git show $HASH2 | grep "O Thor"
100 + git cat-file commit $HASH2 | grep "author A U Thor" &&
101 + R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
102 + git cat-file commit $R | grep "author O Thor" &&
103 + git update-ref refs/replace/$HASH2 $R &&
104 + git show HEAD~5 | grep "O Thor" &&
105 + git show $HASH2 | grep "O Thor"
106 '
107
108 test_expect_success 'test --no-replace-objects option' '
109 - git cat-file commit $HASH2 | grep "author O Thor" &&
110 - git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
111 - git show $HASH2 | grep "O Thor" &&
112 - git --no-replace-objects show $HASH2 | grep "A U Thor"
109 + git cat-file commit $HASH2 | grep "author O Thor" &&
110 + git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
111 + git show $HASH2 | grep "O Thor" &&
112 + git --no-replace-objects show $HASH2 | grep "A U Thor"
113 '
114
115 test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '
116 - GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
117 - GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
116 + GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
117 + GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
118 '
119
120 test_expect_success 'test core.usereplacerefs config option' '
@@ -132,64 +132,64 @@ tagger T A Gger <> 0 +0000
132 EOF
133
134 test_expect_success 'tag replaced commit' '
135 - git update-ref refs/tags/mytag $(git mktag <tag.sig)
135 + git update-ref refs/tags/mytag $(git mktag <tag.sig)
136 '
137
138 test_expect_success '"git fsck" works' '
139 - git fsck main >fsck_main.out &&
140 - test_i18ngrep "dangling commit $R" fsck_main.out &&
141 - test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out &&
142 - test -z "$(git fsck)"
139 + git fsck main >fsck_main.out &&
140 + test_i18ngrep "dangling commit $R" fsck_main.out &&
141 + test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out &&
142 + test -z "$(git fsck)"
143 '
144
145 test_expect_success 'repack, clone and fetch work' '
146 - git repack -a -d &&
147 - git clone --no-hardlinks . clone_dir &&
148 - (
149 - cd clone_dir &&
150 - git show HEAD~5 | grep "A U Thor" &&
151 - git show $HASH2 | grep "A U Thor" &&
152 - git cat-file commit $R &&
153 - git repack -a -d &&
154 - test_must_fail git cat-file commit $R &&
155 - git fetch ../ "refs/replace/*:refs/replace/*" &&
156 - git show HEAD~5 | grep "O Thor" &&
157 - git show $HASH2 | grep "O Thor" &&
158 - git cat-file commit $R
159 - )
146 + git repack -a -d &&
147 + git clone --no-hardlinks . clone_dir &&
148 + (
149 + cd clone_dir &&
150 + git show HEAD~5 | grep "A U Thor" &&
151 + git show $HASH2 | grep "A U Thor" &&
152 + git cat-file commit $R &&
153 + git repack -a -d &&
154 + test_must_fail git cat-file commit $R &&
155 + git fetch ../ "refs/replace/*:refs/replace/*" &&
156 + git show HEAD~5 | grep "O Thor" &&
157 + git show $HASH2 | grep "O Thor" &&
158 + git cat-file commit $R
159 + )
160 '
161
162 test_expect_success '"git replace" listing and deleting' '
163 - test "$HASH2" = "$(git replace -l)" &&
164 - test "$HASH2" = "$(git replace)" &&
165 - aa=${HASH2%??????????????????????????????????????} &&
166 - test "$HASH2" = "$(git replace --list "$aa*")" &&
167 - test_must_fail git replace -d $R &&
168 - test_must_fail git replace --delete &&
169 - test_must_fail git replace -l -d $HASH2 &&
170 - git replace -d $HASH2 &&
171 - git show $HASH2 | grep "A U Thor" &&
172 - test -z "$(git replace -l)"
163 + test "$HASH2" = "$(git replace -l)" &&
164 + test "$HASH2" = "$(git replace)" &&
165 + aa=${HASH2%??????????????????????????????????????} &&
166 + test "$HASH2" = "$(git replace --list "$aa*")" &&
167 + test_must_fail git replace -d $R &&
168 + test_must_fail git replace --delete &&
169 + test_must_fail git replace -l -d $HASH2 &&
170 + git replace -d $HASH2 &&
171 + git show $HASH2 | grep "A U Thor" &&
172 + test -z "$(git replace -l)"
173 '
174
175 test_expect_success '"git replace" replacing' '
176 - git replace $HASH2 $R &&
177 - git show $HASH2 | grep "O Thor" &&
178 - test_must_fail git replace $HASH2 $R &&
179 - git replace -f $HASH2 $R &&
180 - test_must_fail git replace -f &&
181 - test "$HASH2" = "$(git replace)"
176 + git replace $HASH2 $R &&
177 + git show $HASH2 | grep "O Thor" &&
178 + test_must_fail git replace $HASH2 $R &&
179 + git replace -f $HASH2 $R &&
180 + test_must_fail git replace -f &&
181 + test "$HASH2" = "$(git replace)"
182 '
183
184 test_expect_success '"git replace" resolves sha1' '
185 - SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
186 - git replace -d $SHORTHASH2 &&
187 - git replace $SHORTHASH2 $R &&
188 - git show $HASH2 | grep "O Thor" &&
189 - test_must_fail git replace $HASH2 $R &&
190 - git replace -f $HASH2 $R &&
191 - test_must_fail git replace --force &&
192 - test "$HASH2" = "$(git replace)"
185 + SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
186 + git replace -d $SHORTHASH2 &&
187 + git replace $SHORTHASH2 $R &&
188 + git show $HASH2 | grep "O Thor" &&
189 + test_must_fail git replace $HASH2 $R &&
190 + git replace -f $HASH2 $R &&
191 + test_must_fail git replace --force &&
192 + test "$HASH2" = "$(git replace)"
193 '
194
195 # This creates a side branch where the bug in H2
@@ -207,79 +207,79 @@ test_expect_success '"git replace" resolves sha1' '
207 # Then we replace H6 with P6.
208 #
209 test_expect_success 'create parallel branch without the bug' '
210 - git replace -d $HASH2 &&
211 - git show $HASH2 | grep "A U Thor" &&
212 - git checkout $HASH1 &&
213 - git cherry-pick $HASH2 &&
214 - git show $HASH5 | git apply &&
215 - git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
216 - PARA2=$(git rev-parse --verify HEAD) &&
217 - git cherry-pick $HASH3 &&
218 - PARA3=$(git rev-parse --verify HEAD) &&
219 - git cherry-pick $HASH4 &&
220 - PARA4=$(git rev-parse --verify HEAD) &&
221 - git cherry-pick $HASH6 &&
222 - PARA6=$(git rev-parse --verify HEAD) &&
223 - git replace $HASH6 $PARA6 &&
224 - git checkout main &&
225 - cur=$(git rev-parse --verify HEAD) &&
226 - test "$cur" = "$HASH7" &&
227 - git log --pretty=oneline | grep $PARA2 &&
228 - git remote add cloned ./clone_dir
210 + git replace -d $HASH2 &&
211 + git show $HASH2 | grep "A U Thor" &&
212 + git checkout $HASH1 &&
213 + git cherry-pick $HASH2 &&
214 + git show $HASH5 | git apply &&
215 + git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
216 + PARA2=$(git rev-parse --verify HEAD) &&
217 + git cherry-pick $HASH3 &&
218 + PARA3=$(git rev-parse --verify HEAD) &&
219 + git cherry-pick $HASH4 &&
220 + PARA4=$(git rev-parse --verify HEAD) &&
221 + git cherry-pick $HASH6 &&
222 + PARA6=$(git rev-parse --verify HEAD) &&
223 + git replace $HASH6 $PARA6 &&
224 + git checkout main &&
225 + cur=$(git rev-parse --verify HEAD) &&
226 + test "$cur" = "$HASH7" &&
227 + git log --pretty=oneline | grep $PARA2 &&
228 + git remote add cloned ./clone_dir
229 '
230
231 test_expect_success 'push to cloned repo' '
232 - git push cloned $HASH6^:refs/heads/parallel &&
233 - (
234 - cd clone_dir &&
235 - git checkout parallel &&
236 - git log --pretty=oneline | grep $PARA2
237 - )
232 + git push cloned $HASH6^:refs/heads/parallel &&
233 + (
234 + cd clone_dir &&
235 + git checkout parallel &&
236 + git log --pretty=oneline | grep $PARA2
237 + )
238 '
239
240 test_expect_success 'push branch with replacement' '
241 - git cat-file commit $PARA3 | grep "author A U Thor" &&
242 - S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
243 - git cat-file commit $S | grep "author O Thor" &&
244 - git replace $PARA3 $S &&
245 - git show $HASH6~2 | grep "O Thor" &&
246 - git show $PARA3 | grep "O Thor" &&
247 - git push cloned $HASH6^:refs/heads/parallel2 &&
248 - (
249 - cd clone_dir &&
250 - git checkout parallel2 &&
251 - git log --pretty=oneline | grep $PARA3 &&
252 - git show $PARA3 | grep "A U Thor"
253 - )
241 + git cat-file commit $PARA3 | grep "author A U Thor" &&
242 + S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
243 + git cat-file commit $S | grep "author O Thor" &&
244 + git replace $PARA3 $S &&
245 + git show $HASH6~2 | grep "O Thor" &&
246 + git show $PARA3 | grep "O Thor" &&
247 + git push cloned $HASH6^:refs/heads/parallel2 &&
248 + (
249 + cd clone_dir &&
250 + git checkout parallel2 &&
251 + git log --pretty=oneline | grep $PARA3 &&
252 + git show $PARA3 | grep "A U Thor"
253 + )
254 '
255
256 test_expect_success 'fetch branch with replacement' '
257 - git branch tofetch $HASH6 &&
258 - (
259 - cd clone_dir &&
260 - git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
261 - git log --pretty=oneline parallel3 >output.txt &&
262 - ! grep $PARA3 output.txt &&
263 - git show $PARA3 >para3.txt &&
264 - grep "A U Thor" para3.txt &&
265 - git fetch origin "refs/replace/*:refs/replace/*" &&
266 - git log --pretty=oneline parallel3 >output.txt &&
267 - grep $PARA3 output.txt &&
268 - git show $PARA3 >para3.txt &&
269 - grep "O Thor" para3.txt
270 - )
257 + git branch tofetch $HASH6 &&
258 + (
259 + cd clone_dir &&
260 + git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
261 + git log --pretty=oneline parallel3 >output.txt &&
262 + ! grep $PARA3 output.txt &&
263 + git show $PARA3 >para3.txt &&
264 + grep "A U Thor" para3.txt &&
265 + git fetch origin "refs/replace/*:refs/replace/*" &&
266 + git log --pretty=oneline parallel3 >output.txt &&
267 + grep $PARA3 output.txt &&
268 + git show $PARA3 >para3.txt &&
269 + grep "O Thor" para3.txt
270 + )
271 '
272
273 test_expect_success 'bisect and replacements' '
274 - git bisect start $HASH7 $HASH1 &&
275 - test "$PARA3" = "$(git rev-parse --verify HEAD)" &&
276 - git bisect reset &&
277 - GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
278 - test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
279 - git bisect reset &&
280 - git --no-replace-objects bisect start $HASH7 $HASH1 &&
281 - test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
282 - git bisect reset
274 + git bisect start $HASH7 $HASH1 &&
275 + test "$PARA3" = "$(git rev-parse --verify HEAD)" &&
276 + git bisect reset &&
277 + GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
278 + test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
279 + git bisect reset &&
280 + git --no-replace-objects bisect start $HASH7 $HASH1 &&
281 + test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
282 + git bisect reset
283 '
284
285 test_expect_success 'index-pack and replacements' '