Skip to content

Commit 5480207

Browse files
vfr-nlgitster
authored andcommitted
Show error for 'git merge' with unset merge.defaultToUpstream
'git merge' can be called without any arguments if merge.defaultToUpstream is set. However, when merge.defaultToUpstream is not set, the user will be presented the usage information as if he entered a command with a wrong syntaxis. Ironically, the usage information confirms that no arguments are mandatory. This adds a proper error message telling the user why the command failed. As a side-effect this can help the user in discovering the possibility to merge with the upstream branch by setting merge.defaultToUpstream. Signed-off-by: Vincent van Ravesteijn <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd5bce7 commit 5480207

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builtin/merge.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
10941094
die(_("You cannot combine --no-ff with --ff-only."));
10951095

10961096
if (!abort_current_merge) {
1097-
if (!argc && default_to_upstream)
1098-
argc = setup_with_upstream(&argv);
1099-
else if (argc == 1 && !strcmp(argv[0], "-"))
1097+
if (!argc) {
1098+
if (default_to_upstream)
1099+
argc = setup_with_upstream(&argv);
1100+
else
1101+
die(_("No commit specified and merge.defaultToUpstream not set."));
1102+
} else if (argc == 1 && !strcmp(argv[0], "-"))
11001103
argv[0] = "@{-1}";
11011104
}
11021105
if (!argc)

0 commit comments

Comments
 (0)