threads / discuss / 21937

FEATURE REQUEST: Announce branch name with merge comamnd

Subject: FEATURE REQUEST: Announce branch name with merge comamnd

## tl;dr

14 messages between Dec 11, 2009 and Dec 15, 2009.

replies: 13people: 5as markdown or json

Jari Aalto· Dec 11, 2009, 18:55 UTC · lore
Doing octopus merge results:
    $ git merge ...
    Trying simple merge with c87c49b1e413e5dc378d7e6b16951761a1e82f6d
    Trying simple merge with b650c8c8809ef493ad4128fc941ed6b520c82f28
    Trying simple merge with 047f83d6c8a08c4016004780e94257d9e487b7e6
    Simple merge did not work, trying automatic merge.
    Auto-merging example.jwmrc
    Trying simple merge with 16860b016e198acd0814492092e2ad5ea88fb219
    Simple merge did not work, trying automatic merge.
    Auto-merging example.jwmrc
    Trying simple merge with 9a397ff24a381ce49dd093c4f51c06c4c62f3ce7
    Simple merge did not work, trying automatic merge.
    ...
SUGGESTION

Please announce the branch name being merged so that the listing is easier to follow (possibly only with --verbose, -v option). Add "Branch: <name>" just before the merge is attempted. somethiglike this

    Branch: bug--manpage-fix-hyphen
    Trying simple merge with c87c49b1e413e5dc378d7e6b16951761a1e82f6d
    Branch: bug--manpage-fix-TH
    Trying simple merge with b650c8c8809ef493ad4128fc941ed6b520c82f28
    Branch: bug-manpage-change-binary-name
    Trying simple merge with 047f83d6c8a08c4016004780e94257d9e487b7e6
    Branch: feature--example.jwmrc-change-browser
    Simple merge did not work, trying automatic merge.
    Auto-merging example.jwmrc
    Branch: feature--example.jwmrc-change-clock
    Trying simple merge with 16860b016e198acd0814492092e2ad5ea88fb219
    Simple merge did not work, trying automatic merge.
    Auto-merging example.jwmrc
    Branch: feature--example.jwmrc-change-font
    Trying simple merge with 9a397ff24a381ce49dd093c4f51c06c4c62f3ce7
    Simple merge did not work, trying automatic merge.
    ...
Stephen Boyd· Dec 12, 2009, 00:38 UTC · re: Jari Aalto · lore

[PATCH 1/3] octopus: make merge process simpler to follow

Its not very easy to understand what heads are being merged given the current output of an octopus merge. Fix this by replacing the sha1 with the (usually) better description in GITHEAD_<SHA1>.

Suggested-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

Maybe this will work? At least it will replace the sha1 with whatever is given on the command line.

 git-merge-octopus.sh          |    9 +++++----
 t/t7602-merge-octopus-many.sh |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 825c52c..1c8ee0a 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -61,12 +61,13 @@ do
 		exit 2
 	esac
 
+	pretty_name="$(eval echo \$GITHEAD_$SHA1)"
 	common=$(git merge-base --all $SHA1 $MRC) ||
-		die "Unable to find common commit with $SHA1"
+		die "Unable to find common commit with $pretty_name"
 
 	case "$LF$common$LF" in
 	*"$LF$SHA1$LF"*)
-		echo "Already up-to-date with $SHA1"
+		echo "Already up-to-date with $pretty_name"
 		continue
 		;;
 	esac
@@ -81,7 +82,7 @@ do
 		# tree as the intermediate result of the merge.
 		# We still need to count this as part of the parent set.
 
-		echo "Fast-forwarding to: $SHA1"
+		echo "Fast-forwarding to: $pretty_name"
 		git read-tree -u -m $head $SHA1 || exit
 		MRC=$SHA1 MRT=$(git write-tree)
 		continue
@@ -89,7 +90,7 @@ do
 
 	NON_FF_MERGE=1
 
-	echo "Trying simple merge with $SHA1"
+	echo "Trying simple merge with $pretty_name"
 	git read-tree -u -m --aggressive  $common $MRT $SHA1 || exit 2
 	next=$(git write-tree 2>/dev/null)
 	if test $? -ne 0
diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh
index 01e5415..7377033 100755
--- a/t/t7602-merge-octopus-many.sh
+++ b/t/t7602-merge-octopus-many.sh
@@ -49,4 +49,37 @@ test_expect_success 'merge c1 with c2, c3, c4, ... c29' '
 	done
 '
 
+cat >expected <<\EOF
+Trying simple merge with c2
+Trying simple merge with c3
+Trying simple merge with c4
+Merge made by octopus.
+ c2.c |    1 +
+ c3.c |    1 +
+ c4.c |    1 +
+ 3 files changed, 3 insertions(+), 0 deletions(-)
+ create mode 100644 c2.c
+ create mode 100644 c3.c
+ create mode 100644 c4.c
+EOF
+
+test_expect_success 'merge output uses pretty names' '
+	git reset --hard c1 &&
+	git merge c2 c3 c4 >actual &&
+	test_cmp actual expected
+'
+
+cat >expected <<\EOF
+Already up-to-date with c4
+Trying simple merge with c5
+Merge made by octopus.
+ c5.c |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 c5.c
+EOF
+
+test_expect_success 'merge up-to-date output uses pretty names' '
+	git merge c4 c5 >actual &&
+	test_cmp actual expected
+'
 test_done
-- 
1.6.6.rc1.45.g9aadbb
Junio C Hamano· Dec 12, 2009, 08:53 UTC · re: Stephen Boyd · lore

Re: [PATCH 1/3] octopus: make merge process simpler to follow

Stephen Boyd <bebarino@gmail.com> writes:
Show 10 quoted lines
> Its not very easy to understand what heads are being merged given
> the current output of an octopus merge. Fix this by replacing the
> sha1 with the (usually) better description in GITHEAD_<SHA1>.
>
> Suggested-by: Jari Aalto <jari.aalto@cante.net>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>
> Maybe this will work? At least it will replace the sha1 with
> whatever is given on the command line.

This shows what was given from the command line instead of the commit object name. I think it makes sense to not even make this dependent on any option. Also I don't think anybody misses the commit object name in the output---after all, that is all internal to git and is different from what the user gave us anyway (unless the user did give us the full 40-char object name, in which case the value of GITHEAD_<SHA1> would be that name, and we will show it, which is also fine).

No, I haven't applied nor run it yet. The above is purely from my cursory reading of the code.

Anyway, I'll keep this in my inbox or queue it on 'pu' if I had time.
Johannes Sixt· Dec 12, 2009, 19:56 UTC · re: Stephen Boyd · lore

Re: [PATCH 1/3] octopus: make merge process simpler to follow

On Samstag, 12. Dezember 2009, Stephen Boyd wrote:
> +	pretty_name="$(eval echo \$GITHEAD_$SHA1)"
	eval pretty_name=\$GITHEAD_$SHA1
:)
-- Hannes
Junio C Hamano· Dec 12, 2009, 20:46 UTC · re: Johannes Sixt · lore

Re: [PATCH 1/3] octopus: make merge process simpler to follow

Johannes Sixt <j6t@kdbg.org> writes:
Show 6 quoted lines
> On Samstag, 12. Dezember 2009, Stephen Boyd wrote:
>> +	pretty_name="$(eval echo \$GITHEAD_$SHA1)"
>
> 	eval pretty_name=\$GITHEAD_$SHA1
>
> :)

True, and also there can be scripts that call merge-octupos directly without setting "GITHEAD_$commit", so it would probably need something like

	: ${pretty_name:=$SHA1}
after that.
Stephen Boyd· Dec 15, 2009, 06:49 UTC · re: Junio C Hamano · lore

[PATCH] octopus: make merge process simpler to follow

Its not very easy to understand what heads are being merged given the current output of an octopus merge. Fix this by replacing the sha1 with the (usually) better description in GITHEAD_<SHA1>.

Suggested-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Thanks both. Here's a replacement. Let me know if you want a reroll.
 git-merge-octopus.sh          |   11 +++++++----
 t/t7602-merge-octopus-many.sh |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 825c52c..417e8fb 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -61,12 +61,15 @@ do
 		exit 2
 	esac
 
+	eval pretty_name="\$GITHEAD_$SHA1"
+	: ${pretty_name:=$SHA1}
+
 	common=$(git merge-base --all $SHA1 $MRC) ||
-		die "Unable to find common commit with $SHA1"
+		die "Unable to find common commit with $pretty_name"
 
 	case "$LF$common$LF" in
 	*"$LF$SHA1$LF"*)
-		echo "Already up-to-date with $SHA1"
+		echo "Already up-to-date with $pretty_name"
 		continue
 		;;
 	esac
@@ -81,7 +84,7 @@ do
 		# tree as the intermediate result of the merge.
 		# We still need to count this as part of the parent set.
 
-		echo "Fast-forwarding to: $SHA1"
+		echo "Fast-forwarding to: $pretty_name"
 		git read-tree -u -m $head $SHA1 || exit
 		MRC=$SHA1 MRT=$(git write-tree)
 		continue
@@ -89,7 +92,7 @@ do
 
 	NON_FF_MERGE=1
 
-	echo "Trying simple merge with $SHA1"
+	echo "Trying simple merge with $pretty_name"
 	git read-tree -u -m --aggressive  $common $MRT $SHA1 || exit 2
 	next=$(git write-tree 2>/dev/null)
 	if test $? -ne 0
diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh
index 01e5415..7377033 100755
--- a/t/t7602-merge-octopus-many.sh
+++ b/t/t7602-merge-octopus-many.sh
@@ -49,4 +49,37 @@ test_expect_success 'merge c1 with c2, c3, c4, ... c29' '
 	done
 '
 
+cat >expected <<\EOF
+Trying simple merge with c2
+Trying simple merge with c3
+Trying simple merge with c4
+Merge made by octopus.
+ c2.c |    1 +
+ c3.c |    1 +
+ c4.c |    1 +
+ 3 files changed, 3 insertions(+), 0 deletions(-)
+ create mode 100644 c2.c
+ create mode 100644 c3.c
+ create mode 100644 c4.c
+EOF
+
+test_expect_success 'merge output uses pretty names' '
+	git reset --hard c1 &&
+	git merge c2 c3 c4 >actual &&
+	test_cmp actual expected
+'
+
+cat >expected <<\EOF
+Already up-to-date with c4
+Trying simple merge with c5
+Merge made by octopus.
+ c5.c |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ create mode 100644 c5.c
+EOF
+
+test_expect_success 'merge up-to-date output uses pretty names' '
+	git merge c4 c5 >actual &&
+	test_cmp actual expected
+'
 test_done
-- 
1.6.6.rc2.5.g49666
Junio C Hamano· Dec 15, 2009, 07:32 UTC · re: Stephen Boyd · lore

Re: [PATCH] octopus: make merge process simpler to follow

Stephen Boyd <bebarino@gmail.com> writes:
Show 9 quoted lines
> Its not very easy to understand what heads are being merged given
> the current output of an octopus merge. Fix this by replacing the
> sha1 with the (usually) better description in GITHEAD_<SHA1>.
>
> Suggested-by: Jari Aalto <jari.aalto@cante.net>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>
> Thanks both. Here's a replacement. Let me know if you want a reroll.

Ah, thanks and sorry for having you do an extra work. I amended the assignment further like thi,s but haven't got a chance to push the result out...

	eval pretty_name=\${GITHEAD_$SHA1:-$SHA1}
Stephen Boyd· Dec 15, 2009, 07:35 UTC · re: Junio C Hamano · lore

Re: [PATCH] octopus: make merge process simpler to follow

On Mon, 2009-12-14 at 23:32 -0800, Junio C Hamano wrote:
Show 5 quoted lines
> Ah, thanks and sorry for having you do an extra work.  I amended the
> assignment further like thi,s but haven't got a chance to push the result out...
> 
> 	eval pretty_name=\${GITHEAD_$SHA1:-$SHA1}
> 
Great, thanks.
Stephen Boyd· Dec 12, 2009, 00:38 UTC · re: Jari Aalto · lore

[PATCH 2/3] octopus: reenable fast-forward merges

The fast-forward logic is never being triggered because $common and $MRC are never equivalent. $common is initialized to a commit id by merge-base and MRC is initialized to HEAD. Fix this by initializing $MRC to the commit id for HEAD so that its possible for $MRC and $common to be equal.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Found this while making tests up for part 1 of this series.
 git-merge-octopus.sh          |    2 +-
 t/t7602-merge-octopus-many.sh |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 1c8ee0a..99b6f8a 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -44,7 +44,7 @@ esac
 # MRC is the current "merge reference commit"
 # MRT is the current "merge result tree"
 
-MRC=$head MSG= PARENT="-p $head"
+MRC=$(git rev-parse --verify -q $head) MSG= PARENT="-p $head"
 MRT=$(git write-tree)
 CNT=1 ;# counting our head
 NON_FF_MERGE=0
diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh
index 7377033..2746169 100755
--- a/t/t7602-merge-octopus-many.sh
+++ b/t/t7602-merge-octopus-many.sh
@@ -82,4 +82,22 @@ test_expect_success 'merge up-to-date output uses pretty names' '
 	git merge c4 c5 >actual &&
 	test_cmp actual expected
 '
+
+cat >expected <<\EOF
+Fast-forwarding to: c1
+Trying simple merge with c2
+Merge made by octopus.
+ c1.c |    1 +
+ c2.c |    1 +
+ 2 files changed, 2 insertions(+), 0 deletions(-)
+ create mode 100644 c1.c
+ create mode 100644 c2.c
+EOF
+
+test_expect_success 'merge fast-forward output uses pretty names' '
+	git reset --hard c0 &&
+	git merge c1 c2 >actual &&
+	test_cmp actual expected
+'
+
 test_done
-- 
1.6.6.rc1.45.g9aadbb
Stephen Boyd· Dec 12, 2009, 00:38 UTC · re: Jari Aalto · lore

[PATCH 3/3] octopus: remove dead code

MSG, PARENT, and CNT are never used, just assigned to.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

I don't know if this is wanted. Looks like maybe they're used as simple debug aides?

 git-merge-octopus.sh |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 99b6f8a..3cb0b31 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -44,9 +44,8 @@ esac
 # MRC is the current "merge reference commit"
 # MRT is the current "merge result tree"
 
-MRC=$(git rev-parse --verify -q $head) MSG= PARENT="-p $head"
+MRC=$(git rev-parse --verify -q $head)
 MRT=$(git write-tree)
-CNT=1 ;# counting our head
 NON_FF_MERGE=0
 OCTOPUS_FAILURE=0
 for SHA1 in $remotes
@@ -72,9 +71,6 @@ do
 		;;
 	esac
 
-	CNT=`expr $CNT + 1`
-	PARENT="$PARENT -p $SHA1"
-
 	if test "$common,$NON_FF_MERGE" = "$MRC,0"
 	then
 		# The first head being merged was a fast-forward.
-- 
1.6.6.rc1.45.g9aadbb
Junio C Hamano· Dec 12, 2009, 01:01 UTC · re: Stephen Boyd · lore

Re: [PATCH 3/3] octopus: remove dead code

Stephen Boyd <bebarino@gmail.com> writes:
Show 7 quoted lines
> MSG, PARENT, and CNT are never used, just assigned to.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>
> I don't know if this is wanted. Looks like maybe they're used
> as simple debug aides?

No, thanks for spotting. It is the right thing to do to just get rid of them.

IIRC, they are remnants of ancient logic of the script, even before 91063bb (Multi-backend merge driver., 2005-09-08) that added it to the official git history, and were used to update MRC and to come up with the end result (experimental versions of the script used to run "commit-tree" itself).

Alex Riesen· Dec 12, 2009, 01:35 UTC · re: Jari Aalto · lore

Re: FEATURE REQUEST: Announce branch name with merge comamnd

On Fri, Dec 11, 2009 at 19:55, Jari Aalto <jari.aalto@cante.net> wrote:
Show 6 quoted lines
> Please announce the branch name being merged so that the listing is
> easier to follow (possibly only with --verbose, -v option). Add
> "Branch: <name>" just before the merge is attempted. somethiglike this
>
>    Branch: bug--manpage-fix-hyphen
>    Trying simple merge with c87c49b1e413e5dc378d7e6b16951761a1e82f6d

It is not exactly "easier" to follow in your case. It is more text and there is no immediately visible cue that the two lines are related. You have to give the observer this information. Put reference name and SHA-1 on the same line?

Jari Aalto· Dec 12, 2009, 08:35 UTC · re: Alex Riesen · lore

Re: FEATURE REQUEST: Announce branch name with merge comamnd

Alex Riesen <raa.lkml@gmail.com> writes:
Show 13 quoted lines
> On Fri, Dec 11, 2009 at 19:55, Jari Aalto <jari.aalto@cante.net> wrote:
>
>> Please announce the branch name being merged so that the listing is
>> easier to follow (possibly only with --verbose, -v option). Add
>> "Branch: <name>" just before the merge is attempted. somethiglike this
>>
>>    Branch: bug--manpage-fix-hyphen
>>    Trying simple merge with c87c49b1e413e5dc378d7e6b16951761a1e82f6d
>
> It is not exactly "easier" to follow in your case. It is more
> text and there is no immediately visible cue that the two
> lines are related. You have to give the observer this information.
> Put reference name and SHA-1 on the same line?

That would work too. As long as the branch name appears there (optionally only with -v in effect).

Jari

← back to recent threads