git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Show error for 'git merge' with unset merge.defaultToUpstream

From
Vincent van Ravesteijn <vfr@lyx.org>
Date
Nov 21, 2011, 13:30 UTC
Message-ID
<1321882240-3783-1-git-send-email-vfr@lyx.org>

'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 <vfr@lyx.org>
---
 builtin/merge.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index dffd5ec..900a297 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1160,9 +1160,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		die(_("You cannot combine --no-ff with --ff-only."));
 
 	if (!abort_current_merge) {
-		if (!argc && default_to_upstream)
-			argc = setup_with_upstream(&argv);
-		else if (argc == 1 && !strcmp(argv[0], "-"))
+		if (!argc) {
+			if (default_to_upstream)
+				argc = setup_with_upstream(&argv);
+			else
+				die(_("No commit specified and merge.defaultToUpstream not set."));
+		} else if (argc == 1 && !strcmp(argv[0], "-"))
 			argv[0] = "@{-1}";
 	}
 	if (!argc)
-- 
1.7.4.1
Next: Junio C Hamano
Message 1 of 2 in “Show error for 'git merge' with unset merge.defaultToUpstream”
  1. Show error for 'git merge' with unset merge.defaultToUpstreamVincent van Ravesteijn, Nov 21, 2011
  2. Junio C HamanoNov 21, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.