{"thread":{"id":"26468","subject":"[PATCH v4 0/4] Updated patch series for default upstream merge","startedAt":"2011-02-10T23:40:00Z","lastAt":"2011-02-11T07:37:17Z","messageCount":12,"participants":["Jared Hance","Bert Wesarg"],"isPatch":true,"patchVersion":4,"patchTotal":4},"messages":[{"id":"160853","messageId":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":null,"subject":"[PATCH v4 0/4] Updated patch series for default upstream merge","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:00Z","receivedAt":"2011-02-10T23:40:00Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"This patch series allows for `git merge` to default to the upstream of the\ncurrent branch.\n\nThis update adds fixes based on all of the style-feedback from the previous\npatch series; functionally it is equivalent (except for the first patch).\n\nShould I have put the patch submitted by Jonathan Nieder in this series? I\ndidn't place it in the tree but it should apply on top if it.\n\nJared Hance (4):\n  merge: update the usage information to be more modern\n  merge: introduce setup_merge_commit helper function\n  merge: introduce per-branch-configuration helper function\n  merge: add support for merging from upstream by default\n\n Documentation/config.txt |    6 +++\n builtin/merge.c          |   90 ++++++++++++++++++++++++++++++++--------------\n 2 files changed, 69 insertions(+), 27 deletions(-)\n\n-- \n1.7.4\n"},{"id":"160854","messageId":"1297381209-6377-2-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 1/4] merge: update the usage information to be more modern","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:01Z","receivedAt":"2011-02-10T23:40:01Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Apparantly, merge's usage information was outdated and used old terminology.\nFix it.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 42fff38..439d2c7 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -37,8 +37,8 @@ struct strategy {\n };\n \n static const char * const builtin_merge_usage[] = {\n-\t\"git merge [options] <remote>...\",\n-\t\"git merge [options] <msg> HEAD <remote>\",\n+\t\"git merge [options] <branch>...\",\n+\t\"git merge [options] <msg> HEAD <branch>\",\n \tNULL\n };\n \n-- \n1.7.4\n"},{"id":"160862","messageId":"1297381209-6377-3-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 1/5] t5526: Fix wrong argument order in \"git config\"","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:02Z","receivedAt":"2011-02-10T23:40:02Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"From: Jens Lehmann <Jens.Lehmann@web.de>\n\nThis fixes a typo where the \"git config\" arguments \"-f\" and \"--unset\" were\nswapped leading to the creation of a \"--unset\" file.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n t/t5526-fetch-submodules.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh\nindex 884a5e5..a5f4585 100755\n--- a/t/t5526-fetch-submodules.sh\n+++ b/t/t5526-fetch-submodules.sh\n@@ -124,7 +124,7 @@ test_expect_success \"--recurse-submodules overrides fetchRecurseSubmodules setti\n \t(\n \t\tcd downstream &&\n \t\tgit fetch --recurse-submodules >../actual.out 2>../actual.err &&\n-\t\tgit config -f --unset .gitmodules submodule.submodule.fetchRecurseSubmodules true &&\n+\t\tgit config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&\n \t\tgit config --unset submodule.submodule.fetchRecurseSubmodules\n \t) &&\n \ttest_cmp expect.out actual.out &&\n-- \n1.7.4\n"},{"id":"160859","messageId":"1297381209-6377-4-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 2/4] merge: introduce setup_merge_commit helper function","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:03Z","receivedAt":"2011-02-10T23:40:03Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Add a new function to set up a merge commit given a branch\nor commit, which is currently used when parsing argv.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |   44 +++++++++++++++++++++++++++-----------------\n 1 files changed, 27 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 439d2c7..cd23880 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -498,11 +498,15 @@ cleanup:\n \tstrbuf_release(&bname);\n }\n \n-static int git_merge_config(const char *k, const char *v, void *cb)\n+static int per_branch_config(const char *k, const char *v, void *cb)\n {\n-\tif (branch && !prefixcmp(k, \"branch.\") &&\n-\t\t!prefixcmp(k + 7, branch) &&\n-\t\t!strcmp(k + 7 + strlen(branch), \".mergeoptions\")) {\n+\tconst char *variable;\n+\tif (!branch || prefixcmp(k, \"branch.\") ||\n+\t   prefixcmp(k + 7, branch))\n+\t\treturn 1; /* not what I handle */\n+\n+\tvariable = k + 7 + strlen(branch);\n+\tif (!strcmp(variable, \".mergeoptions\")) {\n \t\tconst char **argv;\n \t\tint argc;\n \t\tchar *buf;\n@@ -911,6 +915,24 @@ static int evaluate_result(void)\n \treturn cnt;\n }\n \n+static void setup_merge_commit(struct strbuf *buf,\n+\tstruct commit_list ***remotes, const char *s)\n+{\n+\tstruct object *o;\n+\tstruct commit *commit;\n+\n+\to = peel_to_type(s, 0, NULL, OBJ_COMMIT);\n+\tif (!o)\n+\t\tdie(\"%s - not something we can merge\", s);\n+\tcommit = lookup_commit(o->sha1);\n+\tcommit->util = (void *)s;\n+\t*remotes = &commit_list_insert(commit, *remotes)->next;\n+\n+\tstrbuf_addf(buf, \"GITHEAD_%s\", sha1_to_hex(o->sha1));\n+\tsetenv(buf->buf, s, 1);\n+\tstrbuf_reset(buf);\n+}\n+\n int cmd_merge(int argc, const char **argv, const char *prefix)\n {\n \tunsigned char result_tree[20];\n@@ -1059,19 +1081,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tstrbuf_reset(&buf);\n \n \tfor (i = 0; i < argc; i++) {\n-\t\tstruct object *o;\n-\t\tstruct commit *commit;\n-\n-\t\to = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);\n-\t\tif (!o)\n-\t\t\tdie(\"%s - not something we can merge\", argv[i]);\n-\t\tcommit = lookup_commit(o->sha1);\n-\t\tcommit->util = (void *)argv[i];\n-\t\tremotes = &commit_list_insert(commit, remotes)->next;\n-\n-\t\tstrbuf_addf(&buf, \"GITHEAD_%s\", sha1_to_hex(o->sha1));\n-\t\tsetenv(buf.buf, argv[i], 1);\n-\t\tstrbuf_reset(&buf);\n+\t\tsetup_merge_commit(&buf, &remotes, argv[i]);\n \t}\n \n \tif (!use_strategies) {\n-- \n1.7.4\n"},{"id":"160858","messageId":"1297381209-6377-5-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 2/5] merge: update the usage information to be more modern","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:04Z","receivedAt":"2011-02-10T23:40:04Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Apparantly, merge's usage information was outdated and used old terminology.\nFix it.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 42fff38..439d2c7 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -37,8 +37,8 @@ struct strategy {\n };\n \n static const char * const builtin_merge_usage[] = {\n-\t\"git merge [options] <remote>...\",\n-\t\"git merge [options] <msg> HEAD <remote>\",\n+\t\"git merge [options] <branch>...\",\n+\t\"git merge [options] <msg> HEAD <branch>\",\n \tNULL\n };\n \n-- \n1.7.4\n"},{"id":"160861","messageId":"1297381209-6377-6-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 3/4] merge: introduce per-branch-configuration helper function","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:05Z","receivedAt":"2011-02-10T23:40:05Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Create a new function that will hold configuration code for configuration\nvalues that are specified per branch, as suggested by Junio.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex cd23880..71b392d 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -522,8 +522,20 @@ static int per_branch_config(const char *k, const char *v, void *cb)\n \t\tparse_options(argc, argv, NULL, builtin_merge_options,\n \t\t\t      builtin_merge_usage, 0);\n \t\tfree(buf);\n+\n+\t\treturn 0;\n \t}\n \n+\treturn 1; /* not what I handle */\n+}\n+\n+static int git_merge_config(const char *k, const char *v, void *cb)\n+{\n+\tint status = per_branch_config(k, v, cb);\n+\n+\tif (status <= 0)\n+\t\treturn status;\n+\n \tif (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n \t\tshow_diffstat = git_config_bool(k, v);\n \telse if (!strcmp(k, \"pull.twohead\"))\n-- \n1.7.4\n"},{"id":"160855","messageId":"1297381209-6377-7-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 3/5] merge: introduce setup_merge_commit helper function","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:06Z","receivedAt":"2011-02-10T23:40:06Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Add a new function to set up a merge commit given a branch\nor commit, which is currently used when parsing argv.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |   44 +++++++++++++++++++++++++++-----------------\n 1 files changed, 27 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 439d2c7..cd23880 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -498,11 +498,15 @@ cleanup:\n \tstrbuf_release(&bname);\n }\n \n-static int git_merge_config(const char *k, const char *v, void *cb)\n+static int per_branch_config(const char *k, const char *v, void *cb)\n {\n-\tif (branch && !prefixcmp(k, \"branch.\") &&\n-\t\t!prefixcmp(k + 7, branch) &&\n-\t\t!strcmp(k + 7 + strlen(branch), \".mergeoptions\")) {\n+\tconst char *variable;\n+\tif (!branch || prefixcmp(k, \"branch.\") ||\n+\t   prefixcmp(k + 7, branch))\n+\t\treturn 1; /* not what I handle */\n+\n+\tvariable = k + 7 + strlen(branch);\n+\tif (!strcmp(variable, \".mergeoptions\")) {\n \t\tconst char **argv;\n \t\tint argc;\n \t\tchar *buf;\n@@ -911,6 +915,24 @@ static int evaluate_result(void)\n \treturn cnt;\n }\n \n+static void setup_merge_commit(struct strbuf *buf,\n+\tstruct commit_list ***remotes, const char *s)\n+{\n+\tstruct object *o;\n+\tstruct commit *commit;\n+\n+\to = peel_to_type(s, 0, NULL, OBJ_COMMIT);\n+\tif (!o)\n+\t\tdie(\"%s - not something we can merge\", s);\n+\tcommit = lookup_commit(o->sha1);\n+\tcommit->util = (void *)s;\n+\t*remotes = &commit_list_insert(commit, *remotes)->next;\n+\n+\tstrbuf_addf(buf, \"GITHEAD_%s\", sha1_to_hex(o->sha1));\n+\tsetenv(buf->buf, s, 1);\n+\tstrbuf_reset(buf);\n+}\n+\n int cmd_merge(int argc, const char **argv, const char *prefix)\n {\n \tunsigned char result_tree[20];\n@@ -1059,19 +1081,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tstrbuf_reset(&buf);\n \n \tfor (i = 0; i < argc; i++) {\n-\t\tstruct object *o;\n-\t\tstruct commit *commit;\n-\n-\t\to = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);\n-\t\tif (!o)\n-\t\t\tdie(\"%s - not something we can merge\", argv[i]);\n-\t\tcommit = lookup_commit(o->sha1);\n-\t\tcommit->util = (void *)argv[i];\n-\t\tremotes = &commit_list_insert(commit, remotes)->next;\n-\n-\t\tstrbuf_addf(&buf, \"GITHEAD_%s\", sha1_to_hex(o->sha1));\n-\t\tsetenv(buf.buf, argv[i], 1);\n-\t\tstrbuf_reset(&buf);\n+\t\tsetup_merge_commit(&buf, &remotes, argv[i]);\n \t}\n \n \tif (!use_strategies) {\n-- \n1.7.4\n"},{"id":"160856","messageId":"1297381209-6377-8-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 4/4] merge: add support for merging from upstream by default","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:07Z","receivedAt":"2011-02-10T23:40:07Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Add the option merge.defaultupstream to add support for merging from\nthe upstream branch by default. The upstream branch is found using\nbranch.[name].merge.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n Documentation/config.txt |    6 ++++++\n builtin/merge.c          |   32 +++++++++++++++++++++++---------\n 2 files changed, 29 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c5e1835..4415691 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1389,6 +1389,12 @@ man.<tool>.path::\n \n include::merge-config.txt[]\n \n+merge.defaultUpstream::\n+\tIf merge is called without any ref arguments, merge from the branch\n+\tspecified in branch.<current branch>.merge, which is considered to be\n+\tthe upstream branch for the current branch, possibly set by --track or\n+\t--set-upstream.\n+\n mergetool.<tool>.path::\n \tOverride the path for the given tool.  This is useful in case\n \tyour tool is not in the PATH.\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 71b392d..a3ca6a0 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -37,7 +37,7 @@ struct strategy {\n };\n \n static const char * const builtin_merge_usage[] = {\n-\t\"git merge [options] <branch>...\",\n+\t\"git merge [options] [<branch>...]\",\n \t\"git merge [options] <msg> HEAD <branch>\",\n \tNULL\n };\n@@ -58,6 +58,8 @@ static int option_renormalize;\n static int verbosity;\n static int allow_rerere_auto;\n static int abort_current_merge;\n+static int default_upstream;\n+static const char *upstream_branch;\n \n static struct strategy all_strategy[] = {\n \t{ \"recursive\",  DEFAULT_TWOHEAD | NO_TRIVIAL },\n@@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)\n \t\tfree(buf);\n \n \t\treturn 0;\n-\t}\n+\t} else if (!strcmp(variable, \".merge\"))\n+\t\treturn git_config_string(&upstream_branch, k, v);\n \n \treturn 1; /* not what I handle */\n }\n@@ -536,7 +539,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)\n \tif (status <= 0)\n \t\treturn status;\n \n-\tif (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n+\tif (!strcmp(k, \"merge.defaultupstream\"))\n+\t\tdefault_upstream = git_config_bool(k, v);\n+\telse if (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n \t\tshow_diffstat = git_config_bool(k, v);\n \telse if (!strcmp(k, \"pull.twohead\"))\n \t\treturn git_config_string(&pull_twohead, k, v);\n@@ -1017,9 +1022,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tif (!allow_fast_forward && fast_forward_only)\n \t\tdie(\"You cannot combine --no-ff with --ff-only.\");\n \n-\tif (!argc)\n-\t\tusage_with_options(builtin_merge_usage,\n-\t\t\tbuiltin_merge_options);\n+\tif (!argc) {\n+\t\tif (!default_upstream || !upstream_branch)\n+\t\t\tusage_with_options(builtin_merge_usage,\n+\t\t\t\t\tbuiltin_merge_options);\n+\n+\t\tsetup_merge_commit(&buf, &remotes, upstream_branch);\n+\t}\n \n \t/*\n \t * This could be traditional \"merge <msg> HEAD <commit>...\"  and\n@@ -1082,9 +1091,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t}\n \t}\n \n-\tif (head_invalid || !argc)\n-\t\tusage_with_options(builtin_merge_usage,\n-\t\t\tbuiltin_merge_options);\n+\tif (head_invalid)\n+\t\tusage_msg_opt(\"cannot use old-style invocation from an unborn\"\n+\t\t\t\t\"branch\", \n+\t\t\t\tbuiltin_merge_usage, builtin_merge_options);\n+\n+\tif (!argc && !(default_upstream && upstream_branch))\n+\t\tusage_msg_opt(\"no commit to merge specified\",\n+\t\t\t\tbuiltin_merge_usage, builtin_merge_options);\n \n \tstrbuf_addstr(&buf, \"merge\");\n \tfor (i = 0; i < argc; i++)\n-- \n1.7.4\n"},{"id":"160857","messageId":"1297381209-6377-9-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 4/5] merge: introduce per-branch-configuration helper function","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:08Z","receivedAt":"2011-02-10T23:40:08Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Create a new function that will hold configuration code for configuration\nvalues that are specified per branch, as suggested by Junio.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n builtin/merge.c |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex cd23880..71b392d 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -522,8 +522,20 @@ static int per_branch_config(const char *k, const char *v, void *cb)\n \t\tparse_options(argc, argv, NULL, builtin_merge_options,\n \t\t\t      builtin_merge_usage, 0);\n \t\tfree(buf);\n+\n+\t\treturn 0;\n \t}\n \n+\treturn 1; /* not what I handle */\n+}\n+\n+static int git_merge_config(const char *k, const char *v, void *cb)\n+{\n+\tint status = per_branch_config(k, v, cb);\n+\n+\tif (status <= 0)\n+\t\treturn status;\n+\n \tif (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n \t\tshow_diffstat = git_config_bool(k, v);\n \telse if (!strcmp(k, \"pull.twohead\"))\n-- \n1.7.4\n"},{"id":"160860","messageId":"1297381209-6377-10-git-send-email-jaredhance@gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"[PATCH v4 5/5] merge: add support for merging from upstream by default","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:40:09Z","receivedAt":"2011-02-10T23:40:09Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Add the option merge.defaultupstream to add support for merging from\nthe upstream branch by default. The upstream branch is found using\nbranch.[name].merge.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n Documentation/config.txt |    6 ++++++\n builtin/merge.c          |   32 +++++++++++++++++++++++---------\n 2 files changed, 29 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c5e1835..4415691 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1389,6 +1389,12 @@ man.<tool>.path::\n \n include::merge-config.txt[]\n \n+merge.defaultUpstream::\n+\tIf merge is called without any ref arguments, merge from the branch\n+\tspecified in branch.<current branch>.merge, which is considered to be\n+\tthe upstream branch for the current branch, possibly set by --track or\n+\t--set-upstream.\n+\n mergetool.<tool>.path::\n \tOverride the path for the given tool.  This is useful in case\n \tyour tool is not in the PATH.\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 71b392d..a3ca6a0 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -37,7 +37,7 @@ struct strategy {\n };\n \n static const char * const builtin_merge_usage[] = {\n-\t\"git merge [options] <branch>...\",\n+\t\"git merge [options] [<branch>...]\",\n \t\"git merge [options] <msg> HEAD <branch>\",\n \tNULL\n };\n@@ -58,6 +58,8 @@ static int option_renormalize;\n static int verbosity;\n static int allow_rerere_auto;\n static int abort_current_merge;\n+static int default_upstream;\n+static const char *upstream_branch;\n \n static struct strategy all_strategy[] = {\n \t{ \"recursive\",  DEFAULT_TWOHEAD | NO_TRIVIAL },\n@@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)\n \t\tfree(buf);\n \n \t\treturn 0;\n-\t}\n+\t} else if (!strcmp(variable, \".merge\"))\n+\t\treturn git_config_string(&upstream_branch, k, v);\n \n \treturn 1; /* not what I handle */\n }\n@@ -536,7 +539,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)\n \tif (status <= 0)\n \t\treturn status;\n \n-\tif (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n+\tif (!strcmp(k, \"merge.defaultupstream\"))\n+\t\tdefault_upstream = git_config_bool(k, v);\n+\telse if (!strcmp(k, \"merge.diffstat\") || !strcmp(k, \"merge.stat\"))\n \t\tshow_diffstat = git_config_bool(k, v);\n \telse if (!strcmp(k, \"pull.twohead\"))\n \t\treturn git_config_string(&pull_twohead, k, v);\n@@ -1017,9 +1022,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tif (!allow_fast_forward && fast_forward_only)\n \t\tdie(\"You cannot combine --no-ff with --ff-only.\");\n \n-\tif (!argc)\n-\t\tusage_with_options(builtin_merge_usage,\n-\t\t\tbuiltin_merge_options);\n+\tif (!argc) {\n+\t\tif (!default_upstream || !upstream_branch)\n+\t\t\tusage_with_options(builtin_merge_usage,\n+\t\t\t\t\tbuiltin_merge_options);\n+\n+\t\tsetup_merge_commit(&buf, &remotes, upstream_branch);\n+\t}\n \n \t/*\n \t * This could be traditional \"merge <msg> HEAD <commit>...\"  and\n@@ -1082,9 +1091,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t}\n \t}\n \n-\tif (head_invalid || !argc)\n-\t\tusage_with_options(builtin_merge_usage,\n-\t\t\tbuiltin_merge_options);\n+\tif (head_invalid)\n+\t\tusage_msg_opt(\"cannot use old-style invocation from an unborn\"\n+\t\t\t\t\"branch\", \n+\t\t\t\tbuiltin_merge_usage, builtin_merge_options);\n+\n+\tif (!argc && !(default_upstream && upstream_branch))\n+\t\tusage_msg_opt(\"no commit to merge specified\",\n+\t\t\t\tbuiltin_merge_usage, builtin_merge_options);\n \n \tstrbuf_addstr(&buf, \"merge\");\n \tfor (i = 0; i < argc; i++)\n-- \n1.7.4\n"},{"id":"160863","messageId":"loom.20110211T004608-872@post.gmane.org","threadId":"26468","inReplyTo":"1297381209-6377-1-git-send-email-jaredhance@gmail.com","subject":"Re: [PATCH v4 0/4] Updated patch series for default upstream merge","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2011-02-10T23:47:10Z","receivedAt":"2011-02-10T23:47:10Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Sorry, this came out completely wrong due to some leftover patches in my tree.\nI'll resend a correct one in a few minutes (I just got some feedback that\nsomehow I missed anyway, so some changes need to be made). Ignore this.\n\nMy apologies.\n"},{"id":"160880","messageId":"AANLkTi=F8E02GXDsBzne4Fbrg5a0BEK8N7zS_MoaRE+B@mail.gmail.com","threadId":"26468","inReplyTo":"1297381209-6377-8-git-send-email-jaredhance@gmail.com","subject":"Re: [PATCH v4 4/4] merge: add support for merging from upstream by default","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-02-11T07:37:17Z","receivedAt":"2011-02-11T07:37:17Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Fri, Feb 11, 2011 at 00:40, Jared Hance <jaredhance@gmail.com> wrote:\n> Add the option merge.defaultupstream to add support for merging from\n> the upstream branch by default. The upstream branch is found using\n> branch.[name].merge.\n>\n> Signed-off-by: Jared Hance <jaredhance@gmail.com>\n> ---\n>  Documentation/config.txt |    6 ++++++\n>  builtin/merge.c          |   32 +++++++++++++++++++++++---------\n>  2 files changed, 29 insertions(+), 9 deletions(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index c5e1835..4415691 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -1389,6 +1389,12 @@ man.<tool>.path::\n>\n>  include::merge-config.txt[]\n>\n> +merge.defaultUpstream::\n> +       If merge is called without any ref arguments, merge from the branch\n> +       specified in branch.<current branch>.merge, which is considered to be\n> +       the upstream branch for the current branch, possibly set by --track or\n> +       --set-upstream.\n> +\n>  mergetool.<tool>.path::\n>        Override the path for the given tool.  This is useful in case\n>        your tool is not in the PATH.\n> diff --git a/builtin/merge.c b/builtin/merge.c\n> index 71b392d..a3ca6a0 100644\n> --- a/builtin/merge.c\n> +++ b/builtin/merge.c\n> @@ -37,7 +37,7 @@ struct strategy {\n>  };\n>\n>  static const char * const builtin_merge_usage[] = {\n> -       \"git merge [options] <branch>...\",\n> +       \"git merge [options] [<branch>...]\",\n>        \"git merge [options] <msg> HEAD <branch>\",\n>        NULL\n>  };\n> @@ -58,6 +58,8 @@ static int option_renormalize;\n>  static int verbosity;\n>  static int allow_rerere_auto;\n>  static int abort_current_merge;\n> +static int default_upstream;\n> +static const char *upstream_branch;\n>\n>  static struct strategy all_strategy[] = {\n>        { \"recursive\",  DEFAULT_TWOHEAD | NO_TRIVIAL },\n> @@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)\n>                free(buf);\n>\n>                return 0;\n> -       }\n> +       } else if (!strcmp(variable, \".merge\"))\n> +               return git_config_string(&upstream_branch, k, v);\n\nI don't think, that this is the correct way to get the \"upstream\" from\na branch. Please have a look into sha1_name.c:interpret_branch_name()\nand builtin/for-each-ref.c:populate_value() how they resolve\n\"upstream\".\n\nBert\n"}]}