diff options
author | Elijah Newren <newren@gmail.com> | 2022-08-23 02:42:19 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-24 09:08:32 -0700 |
commit | d3a9295ada961012bfe8582540e40a02e772aa09 (patch) | |
tree | 77cb15bd18a6428b438366bc18138e8dc1988818 /builtin/merge.c | |
parent | fd59c5bdeeb50f18e86f36cbf7a0b82554621690 (diff) | |
download | git-d3a9295ada961012bfe8582540e40a02e772aa09.tar.gz |
merge: only apply autostash when appropriate
If a merge failed and we are leaving conflicts in the working directory
for the user to resolve, we should not attempt to apply any autostash.
Further, if we fail to apply the autostash (because either the merge
failed, or the user requested --no-commit), then we should instruct the
user how to apply it later.
Add a testcase verifying we have corrected this behavior.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r-- | builtin/merge.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index f178f5a3ee..bca91b8a6b 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -492,7 +492,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); } @@ -1754,6 +1755,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) { |