From: Jeff King <hidden> Date: 2016-06-15 22:47:12
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 <redacted>
---
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(-)
Ah, it may have had to do with the fact that it doesn't actually pass
the tests. There is a trivial text update needed in t3409, which calls
"git merge origin/master" during its setup phase.
Updated, passing-all-tests patch is below. Sorry for the confusion.
-- >8 --
Subject: [PATCH] merge: indicate remote tracking branches in merge message
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 <redacted>
---
builtin-merge.c | 11 +++++++++++
t/t3409-rebase-preserve-merges.sh | 2 +-
2 files changed, 12 insertions(+), 1 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:12
Jeff King [off-list ref] writes:
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 <redacted>
---
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.
I somewhat suspect that the patch was not applied because it also lacked
necessary adjustments to tests. With this patch, I think the tests would
fail.
Nevertheless, I think it is a good thing to do. But I am unsure about the
implementation.
Shouldn't it instead feed what it got from the end user to the dwim
machinery, and make sure it dwims into refs/remotes/ hierarchy?
In other words, like this. Note that it would be much clearer to see
what's needed, if you want to extend it to refs/tags hierarchy ;-)
builtin-merge.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
@@ -368,14 +369,17 @@ static void merge_name(const char *remote, struct strbuf *msg)if(!remote_head)die("'%s' does not point to a commit",remote);-strbuf_addstr(&buf,"refs/heads/");-strbuf_addstr(&buf,remote);-resolve_ref(buf.buf,branch_head,0,NULL);--if(!hashcmp(remote_head->sha1,branch_head)){-strbuf_addf(msg,"%s\t\tbranch '%s' of .\n",-sha1_to_hex(branch_head),remote);-gotocleanup;+if(dwim_ref(remote,strlen(remote),branch_head,&found_ref)>0){+if(!prefixcmp(found_ref,"refs/heads/")){+strbuf_addf(msg,"%s\t\tbranch '%s' of .\n",+sha1_to_hex(branch_head),remote);+gotocleanup;+}+if(!prefixcmp(found_ref,"refs/remotes/")){+strbuf_addf(msg,"%s\t\tremote branch '%s' of .\n",+sha1_to_hex(branch_head),remote);+gotocleanup;+}}/* See if remote matches <name>^^^.. or <name>~<number> */
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
On Sun, Aug 09, 2009 at 12:31:04AM -0700, Junio C Hamano wrote:
I somewhat suspect that the patch was not applied because it also lacked
necessary adjustments to tests. With this patch, I think the tests would
fail.
Yeah, see my follow-up patch.
Nevertheless, I think it is a good thing to do. But I am unsure about the
implementation.
Shouldn't it instead feed what it got from the end user to the dwim
machinery, and make sure it dwims into refs/remotes/ hierarchy?
I'm not sure that is all that different in practice than what is
happening now. Mainly I did it the way I did so that I didn't touch the
code path for detecting local branches.
But assuming they are functionally identical, I think your patch is much
more readable.
In other words, like this. Note that it would be much clearer to see
what's needed, if you want to extend it to refs/tags hierarchy ;-)
I'm not sure adding "tag foo" will actually work, as it still has to
make it through the bit where we parse FETCH_HEAD. I'm not sure if it
would get mutilated to "commit foo" by that code or not.
-Peff
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
On Sun, Aug 09, 2009 at 03:40:35AM -0400, Jeff King wrote:
quoted
Shouldn't it instead feed what it got from the end user to the dwim
machinery, and make sure it dwims into refs/remotes/ hierarchy?
I'm not sure that is all that different in practice than what is
happening now. Mainly I did it the way I did so that I didn't touch the
code path for detecting local branches.
But assuming they are functionally identical, I think your patch is much
more readable.
I tested your patch; the two methods aren't identical. In fact, yours
fixes a bug. :)
In t4202, we have a branch name and a tag name that are the same
(octopus-a), and we "git merge octopus-a". This actually merges the tag,
but because the branch name existed, we write "Merge branch 'octopus-a'"
in the log, which is not true. With your patch, it does the right thing
and says "Merge commit 'octopus-a'".
The simple thing is to just update the "expect" text. Though the current
behavior does show off the ability to collape the two branches and say
Merge branches 'octopus-a' and 'octopus-b'
instead of
Merge commit 'octopus-a'; commit 'octopus-b'
which we could preserve that by renaming the tags, as below.
---
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
On Sun, Aug 09, 2009 at 05:14:43AM -0400, Jeff King wrote:
In t4202, we have a branch name and a tag name that are the same
(octopus-a), and we "git merge octopus-a". This actually merges the tag,
but because the branch name existed, we write "Merge branch 'octopus-a'"
in the log, which is not true. With your patch, it does the right thing
and says "Merge commit 'octopus-a'".
The simple thing is to just update the "expect" text. Though the current
behavior does show off the ability to collape the two branches and say
Merge branches 'octopus-a' and 'octopus-b'
instead of
Merge commit 'octopus-a'; commit 'octopus-b'
Thinking about it for a few seconds, it's silly to try to test something
that happens to occur in a totally unrelated test. The right thing to do
is to write actual tests for this area, fix the bug, and then add the
new feature. So how about this series:
[1/3] add tests for merge message headings
[2/3] merge: fix incorrect merge message for ambiguous tag/branch
[3/3] merge: indicate remote tracking branches in merge message
-Peff
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
When calling "git merge $X", we automatically generate a
commit message containing something like "Merge branch
'$X'". This test script checks that those messages say what
they should, and exposes a failure when merging a refname
that is ambiguous between a tag and a branch.
Signed-off-by: Jeff King <redacted>
---
t/t7608-merge-messages.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
create mode 100755 t/t7608-merge-messages.sh
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
If we have both a tag and a branch named "foo", then calling
"git merge foo" will warn about the ambiguous ref, but merge
the tag.
When generating the commit message, though, we simply
checked whether "refs/heads/foo" existed, and if it did,
assumed it was a branch. This led to the statement "Merge
branch 'foo'" in the commit message, which is quite wrong.
Instead, we should use dwim_ref to find the actual ref used,
and describe it appropriately.
In addition to the test in t7608, we must also tweak the
expected output of t4202, which was accidentally triggering
this bug.
Signed-off-by: Jeff King <redacted>
---
builtin-merge.c | 15 +++++++--------
t/t4202-log.sh | 4 ++--
t/t7608-merge-messages.sh | 2 +-
3 files changed, 10 insertions(+), 11 deletions(-)
@@ -368,14 +369,12 @@ static void merge_name(const char *remote, struct strbuf *msg)if(!remote_head)die("'%s' does not point to a commit",remote);-strbuf_addstr(&buf,"refs/heads/");-strbuf_addstr(&buf,remote);-resolve_ref(buf.buf,branch_head,0,NULL);--if(!hashcmp(remote_head->sha1,branch_head)){-strbuf_addf(msg,"%s\t\tbranch '%s' of .\n",-sha1_to_hex(branch_head),remote);-gotocleanup;+if(dwim_ref(remote,strlen(remote),branch_head,&found_ref)>0){+if(!prefixcmp(found_ref,"refs/heads/")){+strbuf_addf(msg,"%s\t\tbranch '%s' of .\n",+sha1_to_hex(branch_head),remote);+gotocleanup;+}}/* See if remote matches <name>^^^.. or <name>~<number> */
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
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.
In addition to a new test in t7608, we have to tweak the
expected output of t3409, which does such a merge.
Signed-off-by: Jeff King <redacted>
---
builtin-merge.c | 5 +++++
t/t3409-rebase-preserve-merges.sh | 2 +-
t/t7608-merge-messages.sh | 10 ++++++++++
3 files changed, 16 insertions(+), 1 deletions(-)
From: Jeff King <hidden> Date: 2016-06-15 22:47:12
On Sun, Aug 09, 2009 at 06:00:45AM -0400, Jeff King wrote:
[1/3] add tests for merge message headings
[2/3] merge: fix incorrect merge message for ambiguous tag/branch
[3/3] merge: indicate remote tracking branches in merge message
And here is the 4/3 you mentioned earlier:
-- >8 --
Subject: [PATCH] merge: describe tags as such in merge message
Previously, merging a tag directly via "git merge tag" would
get you the message "Merge commit 'tag'". It is a little
more descriptive to note that it was actually a tag (i.e.,
"Merge tag 'tag'").
Signed-off-by: Jeff King <redacted>
---
builtin-merge.c | 5 +++++
t/t7608-merge-messages.sh | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)