From 9938f30d13d20026dad2eed7a6b51de25768c858 Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Fri, 23 Jul 2021 12:14:27 +0000 Subject: merge: add missing word "strategy" to a message The variable 'best_strategy' holds the name of the merge strategy that resulted in fewer conflicts, if several strategies were tried. When that's the case but the best strategy was not the first one tried, we inform the user which strategy was the "best" one before recreating the merge and leaving the conflicted files in the tree. This informational message is missing the word "strategy", so it shows something like: Using the recursive to prepare resolving by hand. Fix that. Signed-off-by: Philippe Blain Signed-off-by: Junio C Hamano --- builtin/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/merge.c b/builtin/merge.c index a8a843b1f5..74797b6c7a 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1715,7 +1715,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) else { printf(_("Rewinding the tree to pristine...\n")); restore_state(&head_commit->object.oid, &stash); - printf(_("Using the %s to prepare resolving by hand.\n"), + printf(_("Using the %s strategy to prepare resolving by hand.\n"), best_strategy); try_merge_strategy(best_strategy, common, remoteheads, head_commit); -- cgit v1.2.3 From 12510bd5da6187690ae957d46b41f59276b0dadc Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Fri, 23 Jul 2021 12:14:29 +0000 Subject: merge: apply autostash if fast-forward fails Since 'git merge' learned '--autostash' in a03b55530a (merge: teach --autostash option, 2020-04-07), 'cmd_merge', in the fast-forward case, calls 'create_autostash' before calling 'checkout_fast_forward' if '--autostash' is given. However, if 'checkout_fast_forward' fails, the autostash is not applied to the working tree, nor saved in the stash list, since the code simply calls 'goto done'. Be more helpful to the user by applying the autostash in that case. An easy way to test a failing fast-forward is when we are merging a branch that has a tracked file that conflicts with an untracked file in the working tree. Signed-off-by: Philippe Blain Signed-off-by: Junio C Hamano --- builtin/merge.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/merge.c b/builtin/merge.c index 74797b6c7a..788a6b0cd5 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1560,6 +1560,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) &head_commit->object.oid, &commit->object.oid, overwrite_ignore)) { + apply_autostash(git_path_merge_autostash(the_repository)); ret = 1; goto done; } -- cgit v1.2.3 From e082631e51ebe2c7ee6756a3b45d10732a6480df Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Fri, 23 Jul 2021 12:14:30 +0000 Subject: merge: apply autostash if merge strategy fails Since 'git merge' learned '--autostash' in a03b55530a (merge: teach --autostash option, 2020-04-07), 'cmd_merge', once it is determined that we have to create a merge commit, calls 'create_autostash' if '--autostash' is given. As explained in a03b55530a, and made more abvious by the tests added in that commit, the autostash is then applied if the merge succeeds, either directly or by committing (after conflict resolution or if '--no-commit' was given), or if the merge is aborted with 'git merge --abort'. In some other cases, like the user calling 'git reset --merge' or 'git merge --quit', the autostash is not applied, but saved in the stash list. However, there exists a scenario that creates an autostash but does not apply nor save it to the stash list: if the chosen merge strategy completely fails to handle the merge, i.e. 'try_merge_strategy' returns 2. Apply the autostash in that case also. An easy way to test that is to try to merge more than two commits but explicitely ask for the 'recursive' merge strategy. Signed-off-by: Philippe Blain Signed-off-by: Junio C Hamano --- builtin/merge.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') 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) -- cgit v1.2.3