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 <sunshine@sunshineco.com> Signed-off-by: Mehul Jain <mehul.jain2029@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mehul Jain committed
Apr 2, 2016 at 23:28 UTC
5c82bcddf4f436f137bf0608321c92b8328a270a
1 file changed
+15
-29
t/t5520-pull.sh
+15
-29
@@ -9,6 +9,16 @@ modify () {
9
mv "$2.x" "$2"
10
}
11
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
+
22
test_expect_success setup '
23
echo file >file &&
24
git add file &&
@@ -247,46 +257,22 @@ test_expect_success '--rebase fails with multiple branches' '
257
258
test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
259
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
261
'
262
263
test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
264
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
266
'
267
268
test_expect_success 'pull --rebase --autostash & rebase.autostash=false' '
269
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
271
'
272
281
-test_expect_success 'pull --rebase: --autostash & rebase.autostash unset' '
273
+test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
274
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
276
'
277
278
test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '