* [PATCH v4 0/4] Updated patch series for default upstream merge
@ 2011-02-10 23:40 Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/4] merge: update the usage information to be more modern Jared Hance
` (9 more replies)
0 siblings, 10 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
This patch series allows for `git merge` to default to the upstream of the
current branch.
This update adds fixes based on all of the style-feedback from the previous
patch series; functionally it is equivalent (except for the first patch).
Should I have put the patch submitted by Jonathan Nieder in this series? I
didn't place it in the tree but it should apply on top if it.
Jared Hance (4):
merge: update the usage information to be more modern
merge: introduce setup_merge_commit helper function
merge: introduce per-branch-configuration helper function
merge: add support for merging from upstream by default
Documentation/config.txt | 6 +++
builtin/merge.c | 90 ++++++++++++++++++++++++++++++++--------------
2 files changed, 69 insertions(+), 27 deletions(-)
--
1.7.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 1/4] merge: update the usage information to be more modern
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/5] t5526: Fix wrong argument order in "git config" Jared Hance
` (8 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Apparantly, merge's usage information was outdated and used old terminology.
Fix it.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 42fff38..439d2c7 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -37,8 +37,8 @@ struct strategy {
};
static const char * const builtin_merge_usage[] = {
- "git merge [options] <remote>...",
- "git merge [options] <msg> HEAD <remote>",
+ "git merge [options] <branch>...",
+ "git merge [options] <msg> HEAD <branch>",
NULL
};
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 1/5] t5526: Fix wrong argument order in "git config"
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/4] merge: update the usage information to be more modern Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 2/4] merge: introduce setup_merge_commit helper function Jared Hance
` (7 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jens Lehmann, Junio C Hamano, Jared Hance
From: Jens Lehmann <Jens.Lehmann@web.de>
This fixes a typo where the "git config" arguments "-f" and "--unset" were
swapped leading to the creation of a "--unset" file.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
t/t5526-fetch-submodules.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 884a5e5..a5f4585 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -124,7 +124,7 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti
(
cd downstream &&
git fetch --recurse-submodules >../actual.out 2>../actual.err &&
- git config -f --unset .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
+ git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
git config --unset submodule.submodule.fetchRecurseSubmodules
) &&
test_cmp expect.out actual.out &&
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/4] merge: introduce setup_merge_commit helper function
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/4] merge: update the usage information to be more modern Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/5] t5526: Fix wrong argument order in "git config" Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 2/5] merge: update the usage information to be more modern Jared Hance
` (6 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Add a new function to set up a merge commit given a branch
or commit, which is currently used when parsing argv.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 44 +++++++++++++++++++++++++++-----------------
1 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 439d2c7..cd23880 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -498,11 +498,15 @@ cleanup:
strbuf_release(&bname);
}
-static int git_merge_config(const char *k, const char *v, void *cb)
+static int per_branch_config(const char *k, const char *v, void *cb)
{
- if (branch && !prefixcmp(k, "branch.") &&
- !prefixcmp(k + 7, branch) &&
- !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
+ const char *variable;
+ if (!branch || prefixcmp(k, "branch.") ||
+ prefixcmp(k + 7, branch))
+ return 1; /* not what I handle */
+
+ variable = k + 7 + strlen(branch);
+ if (!strcmp(variable, ".mergeoptions")) {
const char **argv;
int argc;
char *buf;
@@ -911,6 +915,24 @@ static int evaluate_result(void)
return cnt;
}
+static void setup_merge_commit(struct strbuf *buf,
+ struct commit_list ***remotes, const char *s)
+{
+ struct object *o;
+ struct commit *commit;
+
+ o = peel_to_type(s, 0, NULL, OBJ_COMMIT);
+ if (!o)
+ die("%s - not something we can merge", s);
+ commit = lookup_commit(o->sha1);
+ commit->util = (void *)s;
+ *remotes = &commit_list_insert(commit, *remotes)->next;
+
+ strbuf_addf(buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
+ setenv(buf->buf, s, 1);
+ strbuf_reset(buf);
+}
+
int cmd_merge(int argc, const char **argv, const char *prefix)
{
unsigned char result_tree[20];
@@ -1059,19 +1081,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strbuf_reset(&buf);
for (i = 0; i < argc; i++) {
- struct object *o;
- struct commit *commit;
-
- o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
- if (!o)
- die("%s - not something we can merge", argv[i]);
- commit = lookup_commit(o->sha1);
- commit->util = (void *)argv[i];
- remotes = &commit_list_insert(commit, remotes)->next;
-
- strbuf_addf(&buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
- setenv(buf.buf, argv[i], 1);
- strbuf_reset(&buf);
+ setup_merge_commit(&buf, &remotes, argv[i]);
}
if (!use_strategies) {
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/5] merge: update the usage information to be more modern
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (2 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 2/4] merge: introduce setup_merge_commit helper function Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 3/4] merge: introduce per-branch-configuration helper function Jared Hance
` (5 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Apparantly, merge's usage information was outdated and used old terminology.
Fix it.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 42fff38..439d2c7 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -37,8 +37,8 @@ struct strategy {
};
static const char * const builtin_merge_usage[] = {
- "git merge [options] <remote>...",
- "git merge [options] <msg> HEAD <remote>",
+ "git merge [options] <branch>...",
+ "git merge [options] <msg> HEAD <branch>",
NULL
};
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/4] merge: introduce per-branch-configuration helper function
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (3 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 2/5] merge: update the usage information to be more modern Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 3/5] merge: introduce setup_merge_commit " Jared Hance
` (4 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Create a new function that will hold configuration code for configuration
values that are specified per branch, as suggested by Junio.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index cd23880..71b392d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -522,8 +522,20 @@ static int per_branch_config(const char *k, const char *v, void *cb)
parse_options(argc, argv, NULL, builtin_merge_options,
builtin_merge_usage, 0);
free(buf);
+
+ return 0;
}
+ return 1; /* not what I handle */
+}
+
+static int git_merge_config(const char *k, const char *v, void *cb)
+{
+ int status = per_branch_config(k, v, cb);
+
+ if (status <= 0)
+ return status;
+
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
show_diffstat = git_config_bool(k, v);
else if (!strcmp(k, "pull.twohead"))
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/5] merge: introduce setup_merge_commit helper function
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (4 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 3/4] merge: introduce per-branch-configuration helper function Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 4/4] merge: add support for merging from upstream by default Jared Hance
` (3 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Add a new function to set up a merge commit given a branch
or commit, which is currently used when parsing argv.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 44 +++++++++++++++++++++++++++-----------------
1 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 439d2c7..cd23880 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -498,11 +498,15 @@ cleanup:
strbuf_release(&bname);
}
-static int git_merge_config(const char *k, const char *v, void *cb)
+static int per_branch_config(const char *k, const char *v, void *cb)
{
- if (branch && !prefixcmp(k, "branch.") &&
- !prefixcmp(k + 7, branch) &&
- !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
+ const char *variable;
+ if (!branch || prefixcmp(k, "branch.") ||
+ prefixcmp(k + 7, branch))
+ return 1; /* not what I handle */
+
+ variable = k + 7 + strlen(branch);
+ if (!strcmp(variable, ".mergeoptions")) {
const char **argv;
int argc;
char *buf;
@@ -911,6 +915,24 @@ static int evaluate_result(void)
return cnt;
}
+static void setup_merge_commit(struct strbuf *buf,
+ struct commit_list ***remotes, const char *s)
+{
+ struct object *o;
+ struct commit *commit;
+
+ o = peel_to_type(s, 0, NULL, OBJ_COMMIT);
+ if (!o)
+ die("%s - not something we can merge", s);
+ commit = lookup_commit(o->sha1);
+ commit->util = (void *)s;
+ *remotes = &commit_list_insert(commit, *remotes)->next;
+
+ strbuf_addf(buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
+ setenv(buf->buf, s, 1);
+ strbuf_reset(buf);
+}
+
int cmd_merge(int argc, const char **argv, const char *prefix)
{
unsigned char result_tree[20];
@@ -1059,19 +1081,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strbuf_reset(&buf);
for (i = 0; i < argc; i++) {
- struct object *o;
- struct commit *commit;
-
- o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
- if (!o)
- die("%s - not something we can merge", argv[i]);
- commit = lookup_commit(o->sha1);
- commit->util = (void *)argv[i];
- remotes = &commit_list_insert(commit, remotes)->next;
-
- strbuf_addf(&buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
- setenv(buf.buf, argv[i], 1);
- strbuf_reset(&buf);
+ setup_merge_commit(&buf, &remotes, argv[i]);
}
if (!use_strategies) {
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 4/4] merge: add support for merging from upstream by default
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (5 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 3/5] merge: introduce setup_merge_commit " Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-11 7:37 ` Bert Wesarg
2011-02-10 23:40 ` [PATCH v4 4/5] merge: introduce per-branch-configuration helper function Jared Hance
` (2 subsequent siblings)
9 siblings, 1 reply; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Add the option merge.defaultupstream to add support for merging from
the upstream branch by default. The upstream branch is found using
branch.[name].merge.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
Documentation/config.txt | 6 ++++++
builtin/merge.c | 32 +++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5e1835..4415691 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1389,6 +1389,12 @@ man.<tool>.path::
include::merge-config.txt[]
+merge.defaultUpstream::
+ If merge is called without any ref arguments, merge from the branch
+ specified in branch.<current branch>.merge, which is considered to be
+ the upstream branch for the current branch, possibly set by --track or
+ --set-upstream.
+
mergetool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.
diff --git a/builtin/merge.c b/builtin/merge.c
index 71b392d..a3ca6a0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -37,7 +37,7 @@ struct strategy {
};
static const char * const builtin_merge_usage[] = {
- "git merge [options] <branch>...",
+ "git merge [options] [<branch>...]",
"git merge [options] <msg> HEAD <branch>",
NULL
};
@@ -58,6 +58,8 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
+static int default_upstream;
+static const char *upstream_branch;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)
free(buf);
return 0;
- }
+ } else if (!strcmp(variable, ".merge"))
+ return git_config_string(&upstream_branch, k, v);
return 1; /* not what I handle */
}
@@ -536,7 +539,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
if (status <= 0)
return status;
- if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
+ if (!strcmp(k, "merge.defaultupstream"))
+ default_upstream = git_config_bool(k, v);
+ else if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
show_diffstat = git_config_bool(k, v);
else if (!strcmp(k, "pull.twohead"))
return git_config_string(&pull_twohead, k, v);
@@ -1017,9 +1022,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (!allow_fast_forward && fast_forward_only)
die("You cannot combine --no-ff with --ff-only.");
- if (!argc)
- usage_with_options(builtin_merge_usage,
- builtin_merge_options);
+ if (!argc) {
+ if (!default_upstream || !upstream_branch)
+ usage_with_options(builtin_merge_usage,
+ builtin_merge_options);
+
+ setup_merge_commit(&buf, &remotes, upstream_branch);
+ }
/*
* This could be traditional "merge <msg> HEAD <commit>..." and
@@ -1082,9 +1091,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
}
- if (head_invalid || !argc)
- usage_with_options(builtin_merge_usage,
- builtin_merge_options);
+ if (head_invalid)
+ usage_msg_opt("cannot use old-style invocation from an unborn"
+ "branch",
+ builtin_merge_usage, builtin_merge_options);
+
+ if (!argc && !(default_upstream && upstream_branch))
+ usage_msg_opt("no commit to merge specified",
+ builtin_merge_usage, builtin_merge_options);
strbuf_addstr(&buf, "merge");
for (i = 0; i < argc; i++)
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 4/5] merge: introduce per-branch-configuration helper function
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (6 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 4/4] merge: add support for merging from upstream by default Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:40 ` [PATCH v4 5/5] merge: add support for merging from upstream by default Jared Hance
2011-02-10 23:47 ` [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Create a new function that will hold configuration code for configuration
values that are specified per branch, as suggested by Junio.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
builtin/merge.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index cd23880..71b392d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -522,8 +522,20 @@ static int per_branch_config(const char *k, const char *v, void *cb)
parse_options(argc, argv, NULL, builtin_merge_options,
builtin_merge_usage, 0);
free(buf);
+
+ return 0;
}
+ return 1; /* not what I handle */
+}
+
+static int git_merge_config(const char *k, const char *v, void *cb)
+{
+ int status = per_branch_config(k, v, cb);
+
+ if (status <= 0)
+ return status;
+
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
show_diffstat = git_config_bool(k, v);
else if (!strcmp(k, "pull.twohead"))
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 5/5] merge: add support for merging from upstream by default
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (7 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 4/5] merge: introduce per-branch-configuration helper function Jared Hance
@ 2011-02-10 23:40 ` Jared Hance
2011-02-10 23:47 ` [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:40 UTC (permalink / raw)
To: git; +Cc: Jared Hance
Add the option merge.defaultupstream to add support for merging from
the upstream branch by default. The upstream branch is found using
branch.[name].merge.
Signed-off-by: Jared Hance <jaredhance@gmail.com>
---
Documentation/config.txt | 6 ++++++
builtin/merge.c | 32 +++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5e1835..4415691 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1389,6 +1389,12 @@ man.<tool>.path::
include::merge-config.txt[]
+merge.defaultUpstream::
+ If merge is called without any ref arguments, merge from the branch
+ specified in branch.<current branch>.merge, which is considered to be
+ the upstream branch for the current branch, possibly set by --track or
+ --set-upstream.
+
mergetool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.
diff --git a/builtin/merge.c b/builtin/merge.c
index 71b392d..a3ca6a0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -37,7 +37,7 @@ struct strategy {
};
static const char * const builtin_merge_usage[] = {
- "git merge [options] <branch>...",
+ "git merge [options] [<branch>...]",
"git merge [options] <msg> HEAD <branch>",
NULL
};
@@ -58,6 +58,8 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
+static int default_upstream;
+static const char *upstream_branch;
static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)
free(buf);
return 0;
- }
+ } else if (!strcmp(variable, ".merge"))
+ return git_config_string(&upstream_branch, k, v);
return 1; /* not what I handle */
}
@@ -536,7 +539,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
if (status <= 0)
return status;
- if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
+ if (!strcmp(k, "merge.defaultupstream"))
+ default_upstream = git_config_bool(k, v);
+ else if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
show_diffstat = git_config_bool(k, v);
else if (!strcmp(k, "pull.twohead"))
return git_config_string(&pull_twohead, k, v);
@@ -1017,9 +1022,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (!allow_fast_forward && fast_forward_only)
die("You cannot combine --no-ff with --ff-only.");
- if (!argc)
- usage_with_options(builtin_merge_usage,
- builtin_merge_options);
+ if (!argc) {
+ if (!default_upstream || !upstream_branch)
+ usage_with_options(builtin_merge_usage,
+ builtin_merge_options);
+
+ setup_merge_commit(&buf, &remotes, upstream_branch);
+ }
/*
* This could be traditional "merge <msg> HEAD <commit>..." and
@@ -1082,9 +1091,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
}
- if (head_invalid || !argc)
- usage_with_options(builtin_merge_usage,
- builtin_merge_options);
+ if (head_invalid)
+ usage_msg_opt("cannot use old-style invocation from an unborn"
+ "branch",
+ builtin_merge_usage, builtin_merge_options);
+
+ if (!argc && !(default_upstream && upstream_branch))
+ usage_msg_opt("no commit to merge specified",
+ builtin_merge_usage, builtin_merge_options);
strbuf_addstr(&buf, "merge");
for (i = 0; i < argc; i++)
--
1.7.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 0/4] Updated patch series for default upstream merge
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
` (8 preceding siblings ...)
2011-02-10 23:40 ` [PATCH v4 5/5] merge: add support for merging from upstream by default Jared Hance
@ 2011-02-10 23:47 ` Jared Hance
9 siblings, 0 replies; 12+ messages in thread
From: Jared Hance @ 2011-02-10 23:47 UTC (permalink / raw)
To: git
Sorry, this came out completely wrong due to some leftover patches in my tree.
I'll resend a correct one in a few minutes (I just got some feedback that
somehow I missed anyway, so some changes need to be made). Ignore this.
My apologies.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 4/4] merge: add support for merging from upstream by default
2011-02-10 23:40 ` [PATCH v4 4/4] merge: add support for merging from upstream by default Jared Hance
@ 2011-02-11 7:37 ` Bert Wesarg
0 siblings, 0 replies; 12+ messages in thread
From: Bert Wesarg @ 2011-02-11 7:37 UTC (permalink / raw)
To: Jared Hance; +Cc: git, Junio C Hamano, Jeff King
On Fri, Feb 11, 2011 at 00:40, Jared Hance <jaredhance@gmail.com> wrote:
> Add the option merge.defaultupstream to add support for merging from
> the upstream branch by default. The upstream branch is found using
> branch.[name].merge.
>
> Signed-off-by: Jared Hance <jaredhance@gmail.com>
> ---
> Documentation/config.txt | 6 ++++++
> builtin/merge.c | 32 +++++++++++++++++++++++---------
> 2 files changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c5e1835..4415691 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1389,6 +1389,12 @@ man.<tool>.path::
>
> include::merge-config.txt[]
>
> +merge.defaultUpstream::
> + If merge is called without any ref arguments, merge from the branch
> + specified in branch.<current branch>.merge, which is considered to be
> + the upstream branch for the current branch, possibly set by --track or
> + --set-upstream.
> +
> mergetool.<tool>.path::
> Override the path for the given tool. This is useful in case
> your tool is not in the PATH.
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 71b392d..a3ca6a0 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -37,7 +37,7 @@ struct strategy {
> };
>
> static const char * const builtin_merge_usage[] = {
> - "git merge [options] <branch>...",
> + "git merge [options] [<branch>...]",
> "git merge [options] <msg> HEAD <branch>",
> NULL
> };
> @@ -58,6 +58,8 @@ static int option_renormalize;
> static int verbosity;
> static int allow_rerere_auto;
> static int abort_current_merge;
> +static int default_upstream;
> +static const char *upstream_branch;
>
> static struct strategy all_strategy[] = {
> { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
> @@ -524,7 +526,8 @@ static int per_branch_config(const char *k, const char *v, void *cb)
> free(buf);
>
> return 0;
> - }
> + } else if (!strcmp(variable, ".merge"))
> + return git_config_string(&upstream_branch, k, v);
I don't think, that this is the correct way to get the "upstream" from
a branch. Please have a look into sha1_name.c:interpret_branch_name()
and builtin/for-each-ref.c:populate_value() how they resolve
"upstream".
Bert
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-02-11 7:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-10 23:40 [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/4] merge: update the usage information to be more modern Jared Hance
2011-02-10 23:40 ` [PATCH v4 1/5] t5526: Fix wrong argument order in "git config" Jared Hance
2011-02-10 23:40 ` [PATCH v4 2/4] merge: introduce setup_merge_commit helper function Jared Hance
2011-02-10 23:40 ` [PATCH v4 2/5] merge: update the usage information to be more modern Jared Hance
2011-02-10 23:40 ` [PATCH v4 3/4] merge: introduce per-branch-configuration helper function Jared Hance
2011-02-10 23:40 ` [PATCH v4 3/5] merge: introduce setup_merge_commit " Jared Hance
2011-02-10 23:40 ` [PATCH v4 4/4] merge: add support for merging from upstream by default Jared Hance
2011-02-11 7:37 ` Bert Wesarg
2011-02-10 23:40 ` [PATCH v4 4/5] merge: introduce per-branch-configuration helper function Jared Hance
2011-02-10 23:40 ` [PATCH v4 5/5] merge: add support for merging from upstream by default Jared Hance
2011-02-10 23:47 ` [PATCH v4 0/4] Updated patch series for default upstream merge Jared Hance
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.