Imported Upstream version 2.27.0
[platform/upstream/git.git] / t / t5520-pull.sh
index 2f86fca..9fae07c 100755 (executable)
@@ -10,11 +10,13 @@ modify () {
 }
 
 test_pull_autostash () {
+       expect_parent_num="$1" &&
+       shift &&
        git reset --hard before-rebase &&
        echo dirty >new_file &&
        git add new_file &&
        git pull "$@" . copy &&
-       test_cmp_rev HEAD^ copy &&
+       test_cmp_rev HEAD^"$expect_parent_num" copy &&
        echo dirty >expect &&
        test_cmp expect new_file &&
        echo "modified again" >expect &&
@@ -26,7 +28,7 @@ test_pull_autostash_fail () {
        echo dirty >new_file &&
        git add new_file &&
        test_must_fail git pull "$@" . copy 2>err &&
-       test_i18ngrep "uncommitted changes." err
+       test_i18ngrep -E "uncommitted changes.|overwritten by merge:" err
 }
 
 test_expect_success setup '
@@ -369,22 +371,22 @@ test_expect_success '--rebase fails with multiple branches' '
 
 test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
        test_config rebase.autostash true &&
-       test_pull_autostash --rebase
+       test_pull_autostash --rebase
 '
 
 test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
        test_config rebase.autostash true &&
-       test_pull_autostash --rebase --autostash
+       test_pull_autostash --rebase --autostash
 '
 
 test_expect_success 'pull --rebase --autostash & rebase.autostash=false' '
        test_config rebase.autostash false &&
-       test_pull_autostash --rebase --autostash
+       test_pull_autostash --rebase --autostash
 '
 
 test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
        test_unconfig rebase.autostash &&
-       test_pull_autostash --rebase --autostash
+       test_pull_autostash --rebase --autostash
 '
 
 test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '
@@ -402,13 +404,40 @@ test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
        test_pull_autostash_fail --rebase --no-autostash
 '
 
-for i in --autostash --no-autostash
-do
-       test_expect_success "pull $i (without --rebase) is illegal" '
-               test_must_fail git pull $i . copy 2>err &&
-               test_i18ngrep "only valid with --rebase" err
-       '
-done
+test_expect_success 'pull succeeds with dirty working directory and merge.autostash set' '
+       test_config merge.autostash true &&
+       test_pull_autostash 2
+'
+
+test_expect_success 'pull --autostash & merge.autostash=true' '
+       test_config merge.autostash true &&
+       test_pull_autostash 2 --autostash
+'
+
+test_expect_success 'pull --autostash & merge.autostash=false' '
+       test_config merge.autostash false &&
+       test_pull_autostash 2 --autostash
+'
+
+test_expect_success 'pull --autostash & merge.autostash unset' '
+       test_unconfig merge.autostash &&
+       test_pull_autostash 2 --autostash
+'
+
+test_expect_success 'pull --no-autostash & merge.autostash=true' '
+       test_config merge.autostash true &&
+       test_pull_autostash_fail --no-autostash
+'
+
+test_expect_success 'pull --no-autostash & merge.autostash=false' '
+       test_config merge.autostash false &&
+       test_pull_autostash_fail --no-autostash
+'
+
+test_expect_success 'pull --no-autostash & merge.autostash unset' '
+       test_unconfig merge.autostash &&
+       test_pull_autostash_fail --no-autostash
+'
 
 test_expect_success 'pull.rebase' '
        git reset --hard before-rebase &&
@@ -422,7 +451,7 @@ test_expect_success 'pull.rebase' '
 
 test_expect_success 'pull --autostash & pull.rebase=true' '
        test_config pull.rebase true &&
-       test_pull_autostash --autostash
+       test_pull_autostash --autostash
 '
 
 test_expect_success 'pull --no-autostash & pull.rebase=true' '