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

Re: [PATCH] git-gui: pass the branch name to git merge

From
Johannes Sixt <j6t@kdbg.org>
Date
Nov 23, 2016, 22:36 UTC
Message-ID
<e61cc267-a59b-3be1-29db-c49d56f521f7@kdbg.org>
In-Reply-To
<xmqq4m2ym06p.fsf@gitster.mtv.corp.google.com>
Am 23.11.2016 um 21:05 schrieb Junio C Hamano:
Show 17 quoted lines
> Johannes Sixt <j6t@kdbg.org> writes:
>> Am 22.11.2016 um 21:40 schrieb Johannes Sixt:
>>> Am 22.11.2016 um 20:16 schrieb Junio C Hamano:
>>>> Can't this be handled on the "git merge FETCH_HEAD" codepath
>>>> instead?
>>>
>>> Absolutely. Any takers? ;)
>>
>> I attempted to fix git merge FETCH_HEAD, but I do not see a trivial
>> solution.
>>
>> But on second thought, we have an excuse to pick my proposed git-gui
>> change anyway: Without that change and a fix in git-merge only, there
>> is still a regression for all users who use the latest git-gui but
>> some git version between 2.5.0 and the fixed git-merge...
> 
> I'll leave it up to Pat, as I do not read tcl very well ;-)
Sure!

In the mean time, here is my attempt to fix git merge FETCH_HEAD. I would feel better if this were just taken as a starter for a real fix by someone who is familiar with the area.

---- 8< ---- [PATCH] merge FETCH_HEAD: keep track of the branch names

'git merge FETCH_HEAD' is treated differently from 'git merge topic' because FETCH_HEAD is not just a regular ref name, but contains the names of the branches being merged. However, 'git merge' does not store the names as the "remote description" of the merge parent structure that is associated with merged commits, like an ordinary 'git merge topic' call does for the command line arguments. A consequence is that conflict markers are not marked up with the branch name, but with a raw object name. Parse off the branch names from the FETCH_HEAD file and store them with the merged commits.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 builtin/merge.c | 8 ++++++++
 commit.c        | 1 +
 2 files changed, 9 insertions(+)
diff --git a/builtin/merge.c b/builtin/merge.c
index b65eeaa87d..328517b091 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1051,9 +1051,17 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
 			continue; /* not-for-merge */
 		else {
 			char saved = merge_names->buf[pos + 40];
+			char eol = ptr ? *ptr : '\0';
 			merge_names->buf[pos + 40] = '\0';
+			if (ptr)
+				*ptr = '\0';
 			commit = get_merge_parent(merge_names->buf + pos);
+			set_merge_remote_desc(commit,
+					merge_names->buf + pos + 40 + 2,
+					merge_remote_util(commit)->obj);
 			merge_names->buf[pos + 40] = saved;
+			if (ptr)
+				*ptr = eol;
 		}
 		if (!commit) {
 			if (ptr)
diff --git a/commit.c b/commit.c
index 856fd4aeef..7ac2ce6518 100644
--- a/commit.c
+++ b/commit.c
@@ -1582,6 +1582,7 @@ void set_merge_remote_desc(struct commit *commit,
 	struct merge_remote_desc *desc;
 	FLEX_ALLOC_STR(desc, name, name);
 	desc->obj = obj;
+	free(commit->util);
 	commit->util = desc;
 }
 
-- 
2.11.0.rc1.52.g65ffb51
Previous: Junio C Hamano
Message 6 of 6 in “git-gui: pass the branch name to git merge”
  1. git-gui: pass the branch name to git mergeJohannes Sixt, Nov 22, 2016
  2. Junio C HamanoNov 22, 2016
  3. Johannes SixtNov 22, 2016
  4. Johannes SixtNov 23, 2016
  5. Junio C HamanoNov 23, 2016
  6. Johannes SixtNov 23, 2016

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.