{"thread":{"id":"28992","subject":"[PATCH] Show error for 'git merge' with unset merge.defaultToUpstream","startedAt":"2011-11-21T13:30:40Z","lastAt":"2011-11-21T17:30:16Z","messageCount":2,"participants":["Vincent van Ravesteijn","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"179783","messageId":"1321882240-3783-1-git-send-email-vfr@lyx.org","threadId":"28992","inReplyTo":null,"subject":"[PATCH] Show error for 'git merge' with unset merge.defaultToUpstream","fromName":"Vincent van Ravesteijn","fromEmail":"vfr@lyx.org","sentAt":"2011-11-21T13:30:40Z","receivedAt":"2011-11-21T13:30:40Z","isPatch":true,"sender":{"key":"vfr@lyx.org","avatar":"https://avatars.githubusercontent.com/u/687868?v=4"},"body":"'git merge' can be called without any arguments if merge.defaultToUpstream\nis set. However, when merge.defaultToUpstream is not set, the user will be\npresented the usage information as if he entered a command with a wrong\nsyntaxis. Ironically, the usage information confirms that no arguments are\nmandatory.\n\nThis adds a proper error message telling the user why the command failed. As\na side-effect this can help the user in discovering the possibility to merge\nwith the upstream branch by setting merge.defaultToUpstream.\n\nSigned-off-by: Vincent van Ravesteijn <vfr@lyx.org>\n---\n builtin/merge.c |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex dffd5ec..900a297 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1160,9 +1160,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"You cannot combine --no-ff with --ff-only.\"));\n \n \tif (!abort_current_merge) {\n-\t\tif (!argc && default_to_upstream)\n-\t\t\targc = setup_with_upstream(&argv);\n-\t\telse if (argc == 1 && !strcmp(argv[0], \"-\"))\n+\t\tif (!argc) {\n+\t\t\tif (default_to_upstream)\n+\t\t\t\targc = setup_with_upstream(&argv);\n+\t\t\telse\n+\t\t\t\tdie(_(\"No commit specified and merge.defaultToUpstream not set.\"));\n+\t\t} else if (argc == 1 && !strcmp(argv[0], \"-\"))\n \t\t\targv[0] = \"@{-1}\";\n \t}\n \tif (!argc)\n-- \n1.7.4.1\n"},{"id":"179793","messageId":"7vbos5gz87.fsf@alter.siamese.dyndns.org","threadId":"28992","inReplyTo":"1321882240-3783-1-git-send-email-vfr@lyx.org","subject":"Re: [PATCH] Show error for 'git merge' with unset merge.defaultToUpstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-21T17:30:16Z","receivedAt":"2011-11-21T17:30:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Smells correct from a cursory look; thanks.\n"}]}