Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/merge.c1
-rwxr-xr-xt/t7600-merge.sh8
2 files changed, 9 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 788a6b0cd5..d44c14a21a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1709,6 +1709,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
else
fprintf(stderr, _("Merge with strategy %s failed.\n"),
use_strategies[0]->name);
+ apply_autostash(git_path_merge_autostash(the_repository));
ret = 2;
goto done;
} else if (best_strategy == wt_strategy)
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 216113d353..2ef39d3088 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -732,6 +732,14 @@ test_expect_success 'octopus merge with --autostash' '
test_cmp result.1-3-5-9 file
'
+test_expect_success 'failed merge (exit 2) with --autostash' '
+ git reset --hard c1 &&
+ git merge-file file file.orig file.5 &&
+ test_must_fail git merge -s recursive --autostash c2 c3 2>err &&
+ test_i18ngrep "Applied autostash." err &&
+ test_cmp result.1-5 file
+'
+
test_expect_success 'conflicted merge with --autostash, --abort restores stash' '
git reset --hard c3 &&
cp file.1 file &&