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

[PATCH] merge: indicate remote tracking branches in merge message

From
Jeff King <peff@peff.net>
Date
Aug 9, 2009, 06:59 UTC
Message-ID
<20090809065936.GA24112@coredump.intra.peff.net>

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 a repost of
  http://article.gmane.org/gmane.comp.version-control.git/119909

which got no response from you. I think it is a good idea, but I am not deeply committed to it. I mainly want a yes or no so I can clean it out of my patch queue.

 builtin-merge.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index 0b12fb3..c5688e1 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.4.72.g50730
Next: Jeff King
Message 1 of 12 in “merge: indicate remote tracking branches in merge message”
  1. merge: indicate remote tracking branches in merge messageJeff King, Aug 9, 2009
  2. Jeff KingAug 9, 2009
  3. Junio C HamanoAug 9, 2009
  4. Jeff KingAug 9, 2009
  5. Jeff KingAug 9, 2009
  6. Jeff KingAug 9, 2009
  7. 1/3 add tests for merge message headingsJeff King, Aug 9, 2009
  8. 2/3 merge: fix incorrect merge message for ambiguous tag/branchJeff King, Aug 9, 2009
  9. 3/3 merge: indicate remote tracking branches in merge messageJeff King, Aug 9, 2009
  10. Jeff KingAug 9, 2009
  11. Junio C HamanoAug 9, 2009
  12. Jeff KingAug 9, 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.