Skip to content

Commit 5c82bcd

Browse files
mehul2029gitster
authored andcommitted
t5520: factor out common "successful autostash" code
Four tests contains repetitive lines of code. Factor out common code into test_pull_autostash() and then call it in these tests. Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Mehul Jain <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ddc97c commit 5c82bcd

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

t/t5520-pull.sh

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ modify () {
99
mv "$2.x" "$2"
1010
}
1111

12+
test_pull_autostash () {
13+
git reset --hard before-rebase &&
14+
echo dirty >new_file &&
15+
git add new_file &&
16+
git pull "$@" . copy &&
17+
test_cmp_rev HEAD^ copy &&
18+
test "$(cat new_file)" = dirty &&
19+
test "$(cat file)" = "modified again"
20+
}
21+
1222
test_expect_success setup '
1323
echo file >file &&
1424
git add file &&
@@ -247,46 +257,22 @@ test_expect_success '--rebase fails with multiple branches' '
247257

248258
test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
249259
test_config rebase.autostash true &&
250-
git reset --hard before-rebase &&
251-
echo dirty >new_file &&
252-
git add new_file &&
253-
git pull --rebase . copy &&
254-
test_cmp_rev HEAD^ copy &&
255-
test "$(cat new_file)" = dirty &&
256-
test "$(cat file)" = "modified again"
260+
test_pull_autostash --rebase
257261
'
258262

259263
test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
260264
test_config rebase.autostash true &&
261-
git reset --hard before-rebase &&
262-
echo dirty >new_file &&
263-
git add new_file &&
264-
git pull --rebase --autostash . copy &&
265-
test_cmp_rev HEAD^ copy &&
266-
test "$(cat new_file)" = dirty &&
267-
test "$(cat file)" = "modified again"
265+
test_pull_autostash --rebase --autostash
268266
'
269267

270268
test_expect_success 'pull --rebase --autostash & rebase.autostash=false' '
271269
test_config rebase.autostash false &&
272-
git reset --hard before-rebase &&
273-
echo dirty >new_file &&
274-
git add new_file &&
275-
git pull --rebase --autostash . copy &&
276-
test_cmp_rev HEAD^ copy &&
277-
test "$(cat new_file)" = dirty &&
278-
test "$(cat file)" = "modified again"
270+
test_pull_autostash --rebase --autostash
279271
'
280272

281-
test_expect_success 'pull --rebase: --autostash & rebase.autostash unset' '
273+
test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
282274
test_unconfig rebase.autostash &&
283-
git reset --hard before-rebase &&
284-
echo dirty >new_file &&
285-
git add new_file &&
286-
git pull --rebase --autostash . copy &&
287-
test_cmp_rev HEAD^ copy &&
288-
test "$(cat new_file)" = dirty &&
289-
test "$(cat file)" = "modified again"
275+
test_pull_autostash --rebase --autostash
290276
'
291277

292278
test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '

0 commit comments

Comments
 (0)