t5520: factor out common "failing autostash" code
Three tests contains repetitive lines of code. Factor out common code into test_pull_autostash_fail() 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
44a59fff4598f3d2f68b5bc83c75e8483637a33d
1 file changed
+11
-15
t/t5520-pull.sh
+11
-15
@@ -19,6 +19,14 @@ test_pull_autostash () {
19
test "$(cat file)" = "modified again"
20
}
21
22
+test_pull_autostash_fail () {
23
+ git reset --hard before-rebase &&
24
+ echo dirty >new_file &&
25
+ git add new_file &&
26
+ test_must_fail git pull "$@" . copy 2>err &&
27
+ test_i18ngrep "uncommitted changes." err
28
+}
29
+
30
test_expect_success setup '
31
echo file >file &&
32
git add file &&
@@ -277,29 +285,17 @@ test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
285
286
test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '
287
test_config rebase.autostash true &&
280
- git reset --hard before-rebase &&
281
- echo dirty >new_file &&
282
- git add new_file &&
283
- test_must_fail git pull --rebase --no-autostash . copy 2>err &&
284
- test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
288
+ test_pull_autostash_fail --rebase --no-autostash
289
'
290
291
test_expect_success 'pull --rebase --no-autostash & rebase.autostash=false' '
292
test_config rebase.autostash false &&
289
- git reset --hard before-rebase &&
290
- echo dirty >new_file &&
291
- git add new_file &&
292
- test_must_fail git pull --rebase --no-autostash . copy 2>err &&
293
- test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
293
+ test_pull_autostash_fail --rebase --no-autostash
294
'
295
296
test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
297
test_unconfig rebase.autostash &&
298
- git reset --hard before-rebase &&
299
- echo dirty >new_file &&
300
- git add new_file &&
301
- test_must_fail git pull --rebase --no-autostash . copy 2>err &&
302
- test_i18ngrep "Cannot pull with rebase: Your index contains uncommitted changes." err
298
+ test_pull_autostash_fail --rebase --no-autostash
299
'
300
301
test_expect_success 'pull --autostash (without --rebase) should error out' '