git-merge adds test to a message -- bug?
Hi,
is it correct, that this test fails?
t/t6032-merge-message.sh new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='test for merge message' + +. ./test-lib.sh + +test_expect_success setup ' + : > file1 && + git add file1 && + test_tick && + git commit -m "commit 1" && + : > file2 && + git add file2 && + test_tick && + git commit -m "commit 2" && + + git checkout -b new-branch HEAD~1 && + : > file3 && + git add file3 && + test_tick && + git commit -m "commit 3" +' + +test_expect_success merge 'git merge -m master-merge master' + +test_expect_failure 'merge message check' ' + test "$(git cat-file commit HEAD | sed "1,/^\$/d")" = master-merge +' + +test_done
Bye, Jörg.
Signature · 2 lines
Unsere Zweifel sind Verräter und oft genug verspielen wir den möglichen Gewinn, weil wir den Versuch nicht wagen.
Quoted 1 line · Jörg Sommer
is it correct, that this test fails?
Interesting.
The following patch will change the bahaviour to what your test script expects, but by looking at the original code, you can tell that it is indeed the intended behaviour of "-M' to _allow_ you to _prepend_ your own message to the standardized "Merge these" message, not _replace_ with it.
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour. Unless somebody can point out there was a valid reason but that reason is not relevant anymore, I am reluctant to apply the patch below this late in the cycle.
git-merge.sh | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-)
git-merge.sh +13 -11
@@ -250,17 +250,19 @@ else # We are invoked directly as the first-class UI. head_arg=HEAD - # All the rest are the commits being merged; prepare - # the standard merge summary message to be appended to - # the given message. If remote is invalid we will die - # later in the common codepath so we discard the error - # in this loop. - merge_name=$(for remote - do - merge_name "$remote" - done | git fmt-merge-msg - ) - merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name" + if test -z "$merge_msg" + then + # All the rest are the commits being merged; prepare + # the standard merge summary message to be appended to + # the given message. If remote is invalid we will die + # later in the common codepath so we discard the error + # in this loop. + merge_msg=$(for remote + do + merge_name "$remote" + done | git fmt-merge-msg + ) + fi fi head=$(git rev-parse --verify "$head_arg"^0) || usage
Hi,
Quoted 2 lines · Junio C Hamano
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour.
http://article.gmane.org/gmane.comp.version-control.git/31896/match=git+merge+make+usable
Hth,
Dscho
Quoted 8 lines · Johannes Schindelin
Quoted 2 lines · Junio C Hamano
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour.
http://article.gmane.org/gmane.comp.version-control.git/31896/match=git+merge+make+usable
Hth,
Ok, it helped.
So it was "my suspicion that people who would want to pass -m would want it to behave this way".
I do not care deeply either way myself, as I never have found use for -m to the merge command, but I think it could have been argued either way. "If you want to include the standard message, you can do so yourself by running the fmt-merge-msg yourself" would have been a valid argument too, even though it would make it a lot more cumbersome if many people wanted the standard message anyway.
I do not see any objections to the suspicion back then in the thread, there may have been discussions and user requests that made me suspect that nearby as well, and ever since the feature was defined that way there wasn't any objection until Jörg brought this up.
So I'd say we should let the sleeping dog lie for now.
Hallo Junio,
Junio C Hamano schrieb am Mon 24. Mar, 09:45 (-0700):
Quoted 10 lines
Quoted 8 lines · Johannes Schindelin
Quoted 2 lines · Junio C Hamano
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour.
http://article.gmane.org/gmane.comp.version-control.git/31896/match=git+merge+make+usable
Hth,
Quoted 7 lines
Ok, it helped.
So it was "my suspicion that people who would want to pass -m would want it to behave this way".
I do not care deeply either way myself, as I never have found use for -m to the merge command, but I think it could have been argued either way.
I would like to argue for the replace way. :) Take git rebase -p as an example. If a merge is included in the rebase, it's redone with git merge -m. Because git rebase works with detached heads you get merge messages like this:
commit 580c95c6bb4bb74bdbf6776ca816560690c16c5d
Merge: 62b68ef... 9604163...
Author: A U Thor <[email protected]>
Date: Thu Apr 7 15:26:13 2005 -0700
Merge branch 'to-be-preserved' into to-be-rebased
Merge commit '96041635cd9e0bd999384c1c30d7df40002a0742' into HEAD
This is an example from the test t3404. Simply run git log -g and search for merges.
Maybe a new option -M for merge could help? -m with the old behaviour to prepend and -M to replace.
Bye, Jörg.
Signature · 4 lines
IRC: Der [Prof. Andreas Pfitzmann, TU Dresden] hat gerade vorgeschlagen, sie sollen doch statt Trojanern die elektromagnetische Abstrahlung nutzen. Das sei nicht massenfähig, ginge ohne Eingriff ins System, sei zielgerichtet, und, der Hammer, das funktioniere ja bei Wahlcomputern schon sehr gut.
Hi,
Quoted 16 lines · Jörg Sommer
Junio C Hamano schrieb am Mon 24. Mar, 09:45 (-0700):
Quoted 15 lines
Quoted 8 lines · Johannes Schindelin
Quoted 2 lines · Junio C Hamano
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour.
http://article.gmane.org/gmane.comp.version-control.git/31896/match=git+merge+make+usable
Hth,
Ok, it helped.
So it was "my suspicion that people who would want to pass -m would want it to behave this way".
Quoted 8 lines
Quoted 3 lines
I do not care deeply either way myself, as I never have found use for -m to the merge command, but I think it could have been argued either way.
I would like to argue for the replace way. :) Take git rebase -p as an example. If a merge is included in the rebase, it's redone with git merge -m. Because git rebase works with detached heads you get merge messages like this: [...]
That only means that the original author of rebase -p was a lazy bastard and did not use the proper way to call git-merge, namely
git <msg> HEAD <the-other-branch>
Now, let's try git log -S to find out who that inexcusably lazy bum was.
Ciao,
Dscho
Hallo Johannes,
Johannes Schindelin schrieb am Tue 25. Mar, 21:04 (+0100):
Quoted 22 lines · Jörg Sommer
Quoted 12 lines
Junio C Hamano schrieb am Mon 24. Mar, 09:45 (-0700):
Quoted 11 lines
Quoted 6 lines · Johannes Schindelin
Quoted 2 lines · Junio C Hamano
I unfortunately do not recall why _prepend_, and not _replace_, had to be the right behaviour.
http://article.gmane.org/gmane.comp.version-control.git/31896/match=git+merge+make+usable
So it was "my suspicion that people who would want to pass -m would want it to behave this way".
Quoted 8 lines
Quoted 3 lines
I do not care deeply either way myself, as I never have found use for -m to the merge command, but I think it could have been argued either way.
I would like to argue for the replace way. :) Take git rebase -p as an example. If a merge is included in the rebase, it's redone with git merge -m. Because git rebase works with detached heads you get merge messages like this: [...]
Quoted 4 lines
That only means that the original author of rebase -p was a lazy bastard and did not use the proper way to call git-merge, namely
git <msg> HEAD <the-other-branch>
It this really a proper way to call git merge? The manpage says:
The second syntax (<msg> HEAD <remote>) is supported for historical reasons. Do not use it from the command line or in new scripts. It is the same as git merge -m <msg> <remote>.
And how would you pass the option for the strategy to this form? Git rebase calls git merge with -s.
Bye, Jörg.
Signature · 4 lines
But in the case of "git revert", it should be an ancestor (or the user is just insane, in which case it doesn't matter - insane people can do insane things) Linus Torvalds <[email protected]>