From: Junio C Hamano <gitster@pobox.com>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: git@vger.kernel.org, Miklos Vajna <vmiklos@frugalware.org>
Subject: Re* [PATCH] git-merge -s theirs
Date: Mon, 28 Jul 2008 02:18:24 -0700 [thread overview]
Message-ID: <7vfxpus6xr.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vhcak45ez.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Sun, 20 Jul 2008 14:22:28 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Nanako Shiraishi <nanako3@lavabit.com> writes:
> ...
> That is certainly cute, but I do not like it for two reasons:
>
> - This advertizes "theirs" as available when you ask "git merge -s whoa",
> and then the user is told "don't use this stupid, go away". That is
> not exactly a good diplomacy to earn friends.
>
> - The message gives a rather long hexdecimal string in its suggestion to
> run "git reset --hard". This is not exactly your fault, though. The
> original refname the user gave to "git-merge" is not available to your
> strategy.
This does not address the first point at all, but attempts to solve the
second issue. Strategies now get the remote in the symbolic form
originally used on the command line.
All strategies know that they need to expect that the refs can be given
with arbitrary SHA-1 expressions, so this change should be safe.
builtin-merge.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index e78fa18..1a9850f 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -22,6 +22,7 @@
#include "log-tree.h"
#include "color.h"
#include "rerere.h"
+#include "decorate.h"
#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
@@ -504,7 +505,7 @@ static void write_tree_trivial(unsigned char *sha1)
}
static int try_merge_strategy(const char *strategy, struct commit_list *common,
- const char *head_arg)
+ const char *head_arg, struct decoration *symbolic)
{
const char **args;
int i = 0, ret;
@@ -520,8 +521,12 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1));
args[i++] = "--";
args[i++] = head_arg;
- for (j = remoteheads; j; j = j->next)
- args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1));
+ for (j = remoteheads; j; j = j->next) {
+ char *name = lookup_decoration(symbolic, &j->item->object);
+ if (!name)
+ name = sha1_to_hex(j->item->object.sha1);
+ args[i++] = xstrdup(name);
+ }
args[i] = NULL;
ret = run_command_v_opt(args, RUN_GIT_CMD);
strbuf_release(&buf);
@@ -773,6 +778,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
struct commit_list *common = NULL;
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
+ struct decoration symbolic_remote_head;
setup_work_tree();
if (unmerged_cache())
@@ -870,6 +876,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strbuf_addf(&buf, " %s", argv[i]);
setenv("GIT_REFLOG_ACTION", buf.buf, 0);
strbuf_reset(&buf);
+ memset(&symbolic_remote_head, 0, sizeof(symbolic_remote_head));
for (i = 0; i < argc; i++) {
struct object *o;
@@ -877,6 +884,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
if (!o)
die("%s - not something we can merge", argv[i]);
+ add_decoration(&symbolic_remote_head, o, xstrdup(argv[i]));
remotes = &commit_list_insert(lookup_commit(o->sha1),
remotes)->next;
@@ -1041,7 +1049,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
wt_strategy = use_strategies[i]->name;
ret = try_merge_strategy(use_strategies[i]->name,
- common, head_arg);
+ common, head_arg,
+ &symbolic_remote_head);
if (!option_commit && !ret) {
merge_was_ok = 1;
/*
@@ -1105,7 +1114,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
restore_state();
printf("Using the %s to prepare resolving by hand.\n",
best_strategy);
- try_merge_strategy(best_strategy, common, head_arg);
+ try_merge_strategy(best_strategy, common, head_arg,
+ &symbolic_remote_head);
}
if (squash)
prev parent reply other threads:[~2008-07-28 9:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-20 10:21 [PATCH] git-merge -s theirs Nanako Shiraishi
2008-07-20 21:22 ` Junio C Hamano
2008-07-28 9:18 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vfxpus6xr.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=nanako3@lavabit.com \
--cc=vmiklos@frugalware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).