git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git merge remote branch says "Merge commit ..."?

From
Jeff King <peff@peff.net>
Date
May 25, 2009, 09:44 UTC
Message-ID
<20090525094452.GC22382@coredump.intra.peff.net>
In-Reply-To
<7vljoo2mql.fsf@alter.siamese.dyndns.org>
On Sat, May 23, 2009 at 02:26:58AM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> > Right. We could probably use similar logic in "git merge". I'm not sure
> > if it is worth the trouble to end up with "Merge branch 'master' of
> > origin" instead of "Merge remote branch 'origin/master'".
> 
> I do not think it is worth doing that to lose information, either.
So would you be in favor of this patch?
-- >8 --
Subject: [PATCH] merge: indicate remote tracking branches in merge message

Previously when merging directly from a local tracking branch like:

  git merge origin/master
The merge message said:
   Merge commit 'origin/master'
     * commit 'origin/master':
       ...
Instead, let's be more explicit about what we are merging:
   Merge remote branch 'origin/master'
     * origin/master:
       ...

We accomplish this by recognizing remote tracking branches in git-merge when we build the simulated FETCH_HEAD output that we feed to fmt-merge-msg.

Signed-off-by: Jeff King <peff@peff.net>
---
This is not quite identical to the one I posted before; it adds the
magic "of ." at the end of the line, which matches how regular
non-remote branches are handled.
 builtin-merge.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index 0b58e5e..b6f60e9 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -378,6 +378,17 @@ static void merge_name(const char *remote, struct strbuf *msg)
 		goto cleanup;
 	}
 
+	strbuf_setlen(&buf, 0);
+	strbuf_addstr(&buf, "refs/remotes/");
+	strbuf_addstr(&buf, remote);
+	resolve_ref(buf.buf, branch_head, 0, 0);
+
+	if (!hashcmp(remote_head->sha1, branch_head)) {
+		strbuf_addf(msg, "%s\t\tremote branch '%s' of .\n",
+				sha1_to_hex(branch_head), remote);
+		goto cleanup;
+	}
+
 	/* See if remote matches <name>^^^.. or <name>~<number> */
 	for (len = 0, ptr = remote + strlen(remote);
 	     remote < ptr && ptr[-1] == '^';
-- 
1.6.3.1.250.g01b8b.dirty
Previous: Junio C Hamano
Message 10 of 10 in “git merge remote branch says "Merge commit ..."?”
  1. skillzero@gmail.comMay 21, 2009
  2. Jeff KingMay 22, 2009
  3. Eric RaibleMay 22, 2009
  4. Jeff KingMay 22, 2009
  5. Eric RaibleMay 22, 2009
  6. Jeff KingMay 22, 2009
  7. Johannes SixtMay 22, 2009
  8. Jeff KingMay 23, 2009
  9. Junio C HamanoMay 23, 2009
  10. Jeff KingMay 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.