Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-09-03 20:43:42 +0400
committerJunio C Hamano <gitster@pobox.com>2010-09-03 20:43:42 +0400
commit2b916ffa18cb163a9d8f0060a9127e9b0a84b955 (patch)
treec0aa695e824503a78d4f2791119dda4ac66674a0 /builtin
parent8aed4a5e38a2a4f31567e01ab2a73341e972c08a (diff)
parentfdc4408a8980392f2cc30dc125906a61edf170ec (diff)
Merge branch 'jn/update-contrib-example-merge'
* jn/update-contrib-example-merge: (24 commits) merge script: learn --[no-]rerere-autoupdate merge script: notice @{-1} shorthand merge script: handle --no-ff --no-commit correctly merge script: --ff-only to disallow true merge merge script: handle many-way octopus merge script: handle -m --log correctly merge script: forbid merge -s index merge script: allow custom strategies merge script: merge -X<option> merge script: improve log message subject merge script: refuse to merge during merge merge script: tweak unmerged files message to match builtin merge script: --squash, --ff from unborn branch are errors fmt-merge-msg -m to override merge title merge-base --independent to print reduced parent list in a merge merge-base --octopus to mimic show-branch --merge-base Documentation: add a SEE ALSO section for merge-base t6200 (fmt-merge-msg): style nitpicks t6010 (merge-base): modernize style t7600 (merge): test merge from branch yet to be born ...
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fmt-merge-msg.c18
-rw-r--r--builtin/merge-base.c44
-rw-r--r--builtin/merge.c2
3 files changed, 58 insertions, 6 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index a76cd4e9d1..e7e12eea25 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -7,7 +7,7 @@
#include "string-list.h"
static const char * const fmt_merge_msg_usage[] = {
- "git fmt-merge-msg [--log|--no-log] [--file <file>]",
+ "git fmt-merge-msg [-m <message>] [--log|--no-log] [--file <file>]",
NULL
};
@@ -319,11 +319,14 @@ int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
{
const char *inpath = NULL;
+ const char *message = NULL;
struct option options[] = {
OPT_BOOLEAN(0, "log", &merge_summary, "populate log with the shortlog"),
{ OPTION_BOOLEAN, 0, "summary", &merge_summary, NULL,
"alias for --log (deprecated)",
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+ OPT_STRING('m', "message", &message, "text",
+ "use <text> as start of message"),
OPT_FILENAME('F', "file", &inpath, "file to read from"),
OPT_END()
};
@@ -337,6 +340,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
0);
if (argc > 0)
usage_with_options(fmt_merge_msg_usage, options);
+ if (message && !merge_summary) {
+ char nl = '\n';
+ write_in_full(STDOUT_FILENO, message, strlen(message));
+ write_in_full(STDOUT_FILENO, &nl, 1);
+ return 0;
+ }
if (inpath && strcmp(inpath, "-")) {
in = fopen(inpath, "r");
@@ -346,7 +355,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
if (strbuf_read(&input, fileno(in), 0) < 0)
die_errno("could not read input file");
- ret = fmt_merge_msg(merge_summary, &input, &output);
+ if (message) {
+ strbuf_addstr(&output, message);
+ ret = fmt_merge_msg_shortlog(&input, &output);
+ } else {
+ ret = fmt_merge_msg(merge_summary, &input, &output);
+ }
if (ret)
return ret;
write_in_full(STDOUT_FILENO, output.buf, output.len);
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 54e7ec2237..96dd160731 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -23,7 +23,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
}
static const char * const merge_base_usage[] = {
- "git merge-base [-a|--all] <commit> <commit>...",
+ "git merge-base [-a|--all] [--octopus] <commit> <commit>...",
+ "git merge-base --independent <commit>...",
NULL
};
@@ -41,21 +42,58 @@ static struct commit *get_commit_reference(const char *arg)
return r;
}
+static int handle_octopus(int count, const char **args, int reduce, int show_all)
+{
+ struct commit_list *revs = NULL;
+ struct commit_list *result;
+ int i;
+
+ if (reduce)
+ show_all = 1;
+
+ for (i = count - 1; i >= 0; i--)
+ commit_list_insert(get_commit_reference(args[i]), &revs);
+
+ result = reduce ? reduce_heads(revs) : get_octopus_merge_bases(revs);
+
+ if (!result)
+ return 1;
+
+ while (result) {
+ printf("%s\n", sha1_to_hex(result->item->object.sha1));
+ if (!show_all)
+ return 0;
+ result = result->next;
+ }
+
+ return 0;
+}
+
int cmd_merge_base(int argc, const char **argv, const char *prefix)
{
struct commit **rev;
int rev_nr = 0;
int show_all = 0;
+ int octopus = 0;
+ int reduce = 0;
struct option options[] = {
- OPT_BOOLEAN('a', "all", &show_all, "outputs all common ancestors"),
+ OPT_BOOLEAN('a', "all", &show_all, "output all common ancestors"),
+ OPT_BOOLEAN(0, "octopus", &octopus, "find ancestors for a single n-way merge"),
+ OPT_BOOLEAN(0, "independent", &reduce, "list revs not reachable from others"),
OPT_END()
};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, merge_base_usage, 0);
- if (argc < 2)
+ if (!octopus && !reduce && argc < 2)
usage_with_options(merge_base_usage, options);
+ if (reduce && (show_all || octopus))
+ die("--independent cannot be used with other options");
+
+ if (octopus || reduce)
+ return handle_octopus(argc, argv, reduce, show_all);
+
rev = xmalloc(argc * sizeof(*rev));
while (argc-- > 0)
rev[rev_nr++] = get_commit_reference(*argv++);
diff --git a/builtin/merge.c b/builtin/merge.c
index da26cd629a..576e81f145 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -438,7 +438,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
strbuf_addstr(&truname, "refs/heads/");
strbuf_addstr(&truname, remote);
strbuf_setlen(&truname, truname.len - len);
- if (resolve_ref(truname.buf, buf_sha, 0, NULL)) {
+ if (resolve_ref(truname.buf, buf_sha, 1, NULL)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
sha1_to_hex(remote_head->sha1),