git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-gui: pass the branch name to git merge
@ 2016-11-22 17:52 Johannes Sixt
  2016-11-22 19:16 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-11-22 17:52 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: René Scharfe, Junio C Hamano, Git Mailing List

The recent rewrite of the 'git merge' invocation in b5f325cb
(git-gui: stop using deprecated merge syntax) replaced the
subsidiary call of 'git fmt-merge-msg' to take advantage of
the capability of 'git merge' that can construct a merge log
message when the rev being merged is FETCH_HEAD.

A disadvantage of this method is, though, that the conflict
markers are augmented with a raw SHA1 instead of a symbolic
branch name. Revert to the former invocation style so that
we get both a useful commit message and a symbolic name in the
conflict markers.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 A minor regression of our effort to get rid of
 deprecated merge syntax. Even though I had done a number of
 merges since then, I noticed this only today because I
 actively looked for the branch name.

 lib/merge.tcl | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/lib/merge.tcl b/lib/merge.tcl
index 9f253db..39e3fb4 100644
--- a/lib/merge.tcl
+++ b/lib/merge.tcl
@@ -112,16 +112,9 @@ method _start {} {
 	close $fh
 	set _last_merged_branch $branch
 
-	if {[git-version >= "2.5.0"]} {
-		set cmd [list git merge --strategy=recursive FETCH_HEAD]
-	} else {
-		set cmd [list git]
-		lappend cmd merge
-		lappend cmd --strategy=recursive
-		lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]]
-		lappend cmd HEAD
-		lappend cmd $name
-	}
+	set cmd [list git merge --strategy=recursive --no-log -m]
+	lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]]
+	lappend cmd $name
 
 	ui_status [mc "Merging %s and %s..." $current_branch $stitle]
 	set cons [console::new [mc "Merge"] "merge $stitle"]
-- 
2.11.0.rc1.52.g65ffb51


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-gui: pass the branch name to git merge
  2016-11-22 17:52 [PATCH] git-gui: pass the branch name to git merge Johannes Sixt
@ 2016-11-22 19:16 ` Junio C Hamano
  2016-11-22 20:40   ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2016-11-22 19:16 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Pat Thoyts, René Scharfe, Git Mailing List

Johannes Sixt <j6t@kdbg.org> writes:

> The recent rewrite of the 'git merge' invocation in b5f325cb
> (git-gui: stop using deprecated merge syntax) replaced the
> subsidiary call of 'git fmt-merge-msg' to take advantage of
> the capability of 'git merge' that can construct a merge log
> message when the rev being merged is FETCH_HEAD.
>
> A disadvantage of this method is, though, that the conflict
> markers are augmented with a raw SHA1 instead of a symbolic
> branch name.

Can't this be handled on the "git merge FETCH_HEAD" codepath
instead?  The codepath already does enough "magic" things to
FETCH_HEAD like skipping 'not-for-merge' entries and also knows
about the original refnames the commits to be merged came from.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-gui: pass the branch name to git merge
  2016-11-22 19:16 ` Junio C Hamano
@ 2016-11-22 20:40   ` Johannes Sixt
  2016-11-23 19:23     ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-11-22 20:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pat Thoyts, René Scharfe, Git Mailing List

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? ;)

-- Hannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-gui: pass the branch name to git merge
  2016-11-22 20:40   ` Johannes Sixt
@ 2016-11-23 19:23     ` Johannes Sixt
  2016-11-23 20:05       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-11-23 19:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pat Thoyts, René Scharfe, Git Mailing List

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...

-- Hannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-gui: pass the branch name to git merge
  2016-11-23 19:23     ` Johannes Sixt
@ 2016-11-23 20:05       ` Junio C Hamano
  2016-11-23 22:36         ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2016-11-23 20:05 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Pat Thoyts, René Scharfe, Git Mailing List

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 ;-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-gui: pass the branch name to git merge
  2016-11-23 20:05       ` Junio C Hamano
@ 2016-11-23 22:36         ` Johannes Sixt
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2016-11-23 22:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pat Thoyts, René Scharfe, Git Mailing List

Am 23.11.2016 um 21:05 schrieb Junio C Hamano:
> 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-23 22:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 17:52 [PATCH] git-gui: pass the branch name to git merge Johannes Sixt
2016-11-22 19:16 ` Junio C Hamano
2016-11-22 20:40   ` Johannes Sixt
2016-11-23 19:23     ` Johannes Sixt
2016-11-23 20:05       ` Junio C Hamano
2016-11-23 22:36         ` Johannes Sixt

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).