git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Configure default merge message
@ 2021-03-24 18:57 jost.schulte
  2021-03-24 20:01 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: jost.schulte @ 2021-03-24 18:57 UTC (permalink / raw)
  To: Git

Hello all,

I'm using git mainly with BitBucket repositories. When I pull from a remote, the default commit message will be "Merge branch 'source-branch-name' of https://bitbucket.org/ <https://bitbucket.org/jibbletech/jibble-2.0-client-web>repository-name into destination-branch-name".

I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?

Regards
Jost

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

* Re: Configure default merge message
  2021-03-24 18:57 Configure default merge message jost.schulte
@ 2021-03-24 20:01 ` Junio C Hamano
  2021-03-24 22:41   ` Jeff King
  2021-03-25  2:02   ` Ævar Arnfjörð Bjarmason
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2021-03-24 20:01 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Git, jost.schulte

jost.schulte@tutanota.com writes:

> Hello all,
>
> I'm using git mainly with BitBucket repositories. When I pull from a remote, the default commit message will be "Merge branch 'source-branch-name' of https://bitbucket.org/ <https://bitbucket.org/jibbletech/jibble-2.0-client-web>repository-name into destination-branch-name".
>
> I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?
>
> Regards
> Jost

Ævar, is this something we recently made it impossible with 4e168333
(shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12), or
is there more to it than resurrecting that "feature" to do what Jost
seems to want?

Thanks.

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

* Re: Configure default merge message
  2021-03-24 20:01 ` Junio C Hamano
@ 2021-03-24 22:41   ` Jeff King
  2021-03-25  2:02   ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2021-03-24 22:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ævar Arnfjörð Bjarmason, Git, jost.schulte

On Wed, Mar 24, 2021 at 01:01:42PM -0700, Junio C Hamano wrote:

> > I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?
> 
> Ævar, is this something we recently made it impossible with 4e168333
> (shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12), or
> is there more to it than resurrecting that "feature" to do what Jost
> seems to want?

IIRC, in that earlier discussion Linus said he used a prepare-commit-msg
hook these days instead of repo-abbrev. And it should be able to handle
this case, as well.

Something like this seems to work for me:

  $ cat .git/hooks/prepare-commit-msg
  #!/bin/sh
  case "$2" in
  merge)
  	perl -i -pe '
  	  s{Merge (.*) of https://github.com/gitster/git}{Merge $1}
  	' "$1"
  	;;
  esac

  $ git pull https://github.com/gitster/git next
  [...]
  $ git log -1 --format=%s
  Merge branch 'next'

-Peff

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

* Re: Configure default merge message
  2021-03-24 20:01 ` Junio C Hamano
  2021-03-24 22:41   ` Jeff King
@ 2021-03-25  2:02   ` Ævar Arnfjörð Bjarmason
  2021-03-26  6:30     ` jost.schulte
       [not found]     ` <MWhDNa_--3-2@tutanota.com>
  1 sibling, 2 replies; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-03-25  2:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git, jost.schulte, Jeff King


On Wed, Mar 24 2021, Junio C Hamano wrote:

> jost.schulte@tutanota.com writes:
>
>> Hello all,
>>
>> I'm using git mainly with BitBucket repositories. When I pull from a remote, the default commit message will be "Merge branch 'source-branch-name' of https://bitbucket.org/ <https://bitbucket.org/jibbletech/jibble-2.0-client-web>repository-name into destination-branch-name".
>>
>> I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?
>>
>> Regards
>> Jost
>
> Ævar, is this something we recently made it impossible with 4e168333
> (shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12), or
> is there more to it than resurrecting that "feature" to do what Jost
> seems to want?

Perhaps I'm using it incorrectly, but I don't see how that repo-abbrev
feature ever resulted in the insertion of this munged content into the
actual commit object.

The shortlog examples of "..." in 4e168333 are of shortlog's output
being modified on the fly. Not of them being inserted into commits.

You can run "git merge" with "--log" which says it inserts "shortlog"
output. So I thought that maybe lines that were not the first "Merge
... into" line in the message could have gotten munged in this way
before my change.

But I don't think that happened either, and reverting 4e168333 and doing
a merge --log locally with e.g. "# repo-abbrev: branch" does not munge
the string "branch" in either the subject or the body, it's retained,
e.g.:
    
    commit 02c864e58da (HEAD)
    Merge: 353c73510dc c6d63de00ff
    Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
    Date:   Thu Mar 25 03:00:21 2021 +0100
    
        Merge branch 'to-merge' into HEAD
        
        * to-merge:
          Merge this branch blah blah
    

That's because "merge" never used the munging.

If you look at the code in 7595e2ee6ef (git-shortlog: make common
repository prefix configurable with .mailmap, 2006-11-25) when this
repo-abbrev feature was first added the "merge" would use
builtin-fmt-merge-msg.c to format the "shortlog", which implemented its
own function to do so, and didn't use the mailmap.

As to Jost's question. I think the way to do this is to use
fmt-merge-msg, see 2102440c17f (fmt-merge-msg -m to override merge
title, 2010-08-17) for an example.

That seems like it would also be simpler than Jeff King's suggestion in
the side-thread in <YFvAJU3Euxhjb+uw@coredump.intra.peff.net>.

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

* Re: Configure default merge message
  2021-03-25  2:02   ` Ævar Arnfjörð Bjarmason
@ 2021-03-26  6:30     ` jost.schulte
       [not found]     ` <MWhDNa_--3-2@tutanota.com>
  1 sibling, 0 replies; 6+ messages in thread
From: jost.schulte @ 2021-03-26  6:30 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Junio C Hamano, Git, Jeff King

Thank you for the detailed explanation. Where can I see the commits that you mention?

25 Mar 2021, 03:02 by avarab@gmail.com:

>
> On Wed, Mar 24 2021, Junio C Hamano wrote:
>
>> jost.schulte@tutanota.com writes:
>>
>>> Hello all,
>>>
>>> I'm using git mainly with BitBucket repositories. When I pull from a remote, the default commit message will be "Merge branch 'source-branch-name' of https://bitbucket.org/ <https://bitbucket.org/jibbletech/jibble-2.0-client-web>repository-name into destination-branch-name".
>>>
>>> I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?
>>>
>>> Regards
>>> Jost
>>>
>>
>> Ævar, is this something we recently made it impossible with 4e168333
>> (shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12), or
>> is there more to it than resurrecting that "feature" to do what Jost
>> seems to want?
>>
>
> Perhaps I'm using it incorrectly, but I don't see how that repo-abbrev
> feature ever resulted in the insertion of this munged content into the
> actual commit object.
>
> The shortlog examples of "..." in 4e168333 are of shortlog's output
> being modified on the fly. Not of them being inserted into commits.
>
> You can run "git merge" with "--log" which says it inserts "shortlog"
> output. So I thought that maybe lines that were not the first "Merge
> ... into" line in the message could have gotten munged in this way
> before my change.
>
> But I don't think that happened either, and reverting 4e168333 and doing
> a merge --log locally with e.g. "# repo-abbrev: branch" does not munge
> the string "branch" in either the subject or the body, it's retained,
> e.g.:
>  
>  commit 02c864e58da (HEAD)
>  Merge: 353c73510dc c6d63de00ff
>  Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>  Date:   Thu Mar 25 03:00:21 2021 +0100
>  
>  Merge branch 'to-merge' into HEAD
>  
>  * to-merge:
>  Merge this branch blah blah
>  
>
> That's because "merge" never used the munging.
>
> If you look at the code in 7595e2ee6ef (git-shortlog: make common
> repository prefix configurable with .mailmap, 2006-11-25) when this
> repo-abbrev feature was first added the "merge" would use
> builtin-fmt-merge-msg.c to format the "shortlog", which implemented its
> own function to do so, and didn't use the mailmap.
>
> As to Jost's question. I think the way to do this is to use
> fmt-merge-msg, see 2102440c17f (fmt-merge-msg -m to override merge
> title, 2010-08-17) for an example.
>
> That seems like it would also be simpler than Jeff King's suggestion in
> the side-thread in <YFvAJU3Euxhjb+uw@coredump.intra.peff.net>.
>

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

* Re: Configure default merge message
       [not found]     ` <MWhDNa_--3-2@tutanota.com>
@ 2021-03-26 10:43       ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-03-26 10:43 UTC (permalink / raw)
  To: jost.schulte; +Cc: Junio C Hamano, Git, Jeff King


On Fri, Mar 26 2021, jost.schulte@tutanota.com wrote:

> 25 Mar 2021, 03:02 by avarab@gmail.com:
>
>>
>> On Wed, Mar 24 2021, Junio C Hamano wrote:
>>
>>> jost.schulte@tutanota.com writes:
>>>
>>>> Hello all,
>>>>
>>>> I'm using git mainly with BitBucket repositories. When I pull from a remote, the default commit message will be "Merge branch 'source-branch-name' of https://bitbucket.org/ <https://bitbucket.org/jibbletech/jibble-2.0-client-web>repository-name into destination-branch-name".
>>>>
>>>> I'd like to configure git to omit the "of https://bitbucket.org/repository-name" part. How can I do that?
>>>>
>>>> Regards
>>>> Jost
>>>>
>>>
>>> Ævar, is this something we recently made it impossible with 4e168333
>>> (shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12), or
>>> is there more to it than resurrecting that "feature" to do what Jost
>>> seems to want?
>>>
>>
>> Perhaps I'm using it incorrectly, but I don't see how that repo-abbrev
>> feature ever resulted in the insertion of this munged content into the
>> actual commit object.
>>
>> The shortlog examples of "..." in 4e168333 are of shortlog's output
>> being modified on the fly. Not of them being inserted into commits.
>>
>> You can run "git merge" with "--log" which says it inserts "shortlog"
>> output. So I thought that maybe lines that were not the first "Merge
>> ... into" line in the message could have gotten munged in this way
>> before my change.
>>
>> But I don't think that happened either, and reverting 4e168333 and doing
>> a merge --log locally with e.g. "# repo-abbrev: branch" does not munge
>> the string "branch" in either the subject or the body, it's retained,
>> e.g.:
>>  
>>  commit 02c864e58da (HEAD)
>>  Merge: 353c73510dc c6d63de00ff
>>  Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>>  Date:   Thu Mar 25 03:00:21 2021 +0100
>>  
>>  Merge branch 'to-merge' into HEAD
>>  
>>  * to-merge:
>>  Merge this branch blah blah
>>  
>>
>> That's because "merge" never used the munging.
>>
>> If you look at the code in 7595e2ee6ef (git-shortlog: make common
>> repository prefix configurable with .mailmap, 2006-11-25) when this
>> repo-abbrev feature was first added the "merge" would use
>> builtin-fmt-merge-msg.c to format the "shortlog", which implemented its
>> own function to do so, and didn't use the mailmap.
>>
>> As to Jost's question. I think the way to do this is to use
>> fmt-merge-msg, see 2102440c17f (fmt-merge-msg -m to override merge
>> title, 2010-08-17) for an example.
>>
>> That seems like it would also be simpler than Jeff King's suggestion in
>> the side-thread in <YFvAJU3Euxhjb+uw@coredump.intra.peff.net>.
>>
>
> Thank you for the detailed explanation. Where can I see the commits
> that you mention?

[It's good practice on this mailing list not to top-post]

4e168333 is a commit in your copy of the git.git repository.

The 02c864e58da, 353c73510dc and c6d63de00ff are just something that was
part of a throwaway experiment I ran locally.

I created two branches based on git.git's 238803cb409 (the commit before
4e168333), one added a repo-abbrev line to .mailmap, the other had a
string in the subject/body that would match that repo-abbrev.

So the merge shows that the "branch" string was not replaced with "...".


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

end of thread, other threads:[~2021-03-26 10:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 18:57 Configure default merge message jost.schulte
2021-03-24 20:01 ` Junio C Hamano
2021-03-24 22:41   ` Jeff King
2021-03-25  2:02   ` Ævar Arnfjörð Bjarmason
2021-03-26  6:30     ` jost.schulte
     [not found]     ` <MWhDNa_--3-2@tutanota.com>
2021-03-26 10:43       ` Ævar Arnfjörð Bjarmason

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 NNTP newsgroup(s).