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:
authorJunio C Hamano <gitster@pobox.com>2022-09-01 23:40:18 +0300
committerJunio C Hamano <gitster@pobox.com>2022-09-01 23:40:18 +0300
commit3a4779086deb12d406f819a619cc28924461f1a4 (patch)
treeeeb561dc9b266d4b1887762ef90253d51364fe4b
parentd528044c83cc1f5fb925fbb043110f5fb0382f99 (diff)
parentd3a9295ada961012bfe8582540e40a02e772aa09 (diff)
Merge branch 'en/merge-unstash-only-on-clean-merge'
The auto-stashed local changes created by "git merge --autostash" was mixed into a conflicted state left in the working tree, which has been corrected. * en/merge-unstash-only-on-clean-merge: merge: only apply autostash when appropriate
-rw-r--r--builtin/merge.c5
-rwxr-xr-xt/t7600-merge.sh9
2 files changed, 13 insertions, 1 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index f7c92c0e64..b4253710d1 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -503,7 +503,8 @@ static void finish(struct commit *head_commit,
/* Run a post-merge hook */
run_hooks_l("post-merge", squash ? "1" : "0", NULL);
- apply_autostash(git_path_merge_autostash(the_repository));
+ if (new_head)
+ apply_autostash(git_path_merge_autostash(the_repository));
strbuf_release(&reflog_message);
}
@@ -1781,6 +1782,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
"stopped before committing as requested\n"));
else
ret = suggest_conflicts();
+ if (autostash)
+ printf(_("When finished, apply stashed changes with `git stash pop`\n"));
done:
if (!automerge_was_ok) {
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index f0f6fda150..7c3f6ed994 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -255,6 +255,15 @@ test_expect_success 'merge --squash c3 with c7' '
test_cmp expect actual
'
+test_expect_success 'merge --squash --autostash conflict does not attempt to apply autostash' '
+ git reset --hard c3 &&
+ >unrelated &&
+ git add unrelated &&
+ test_must_fail git merge --squash c7 --autostash >out 2>err &&
+ ! grep "Applying autostash resulted in conflicts." err &&
+ grep "When finished, apply stashed changes with \`git stash pop\`" out
+'
+
test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' '
git config commit.cleanup scissors &&
git reset --hard c3 &&