threads / discuss / 41599

Feature request: Configurable prefixes for git commit --fixup and --squash

Subject: Feature request: Configurable prefixes for git commit --fixup and --squash

## tl;dr

12 messages between Mar 3, 2016 and Mar 3, 2016.

replies: 11people: 4as markdown or json

Martine Lenders· Mar 3, 2016, 12:47 UTC · lore

Hi, I'm not sure if this was already requested somewhere (a quick - but admittedly not thorough - search did not reveal anything in that direction), but I really miss an option to configure the prefixes generated by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase -i --autosquash`.

My reasoning is that in our project we use GitHub + Travis to test-build our pull requests, but we don't want to spam the CI server with builds that are just fixups to previous changes (which are uploaded so reviewers can track the changes to the original PR). Now, Travis has the option to not build a commit if there is the string `[ci skip]` in the commit message (sadly also not configurable) so it would be really great for my workflow if I could just add this string to the message generated by `--fixup`.

Thanks in advance for your consideration.

Kind Regards, Martine Lenders

John Keeping· Mar 3, 2016, 13:21 UTC · re: Martine Lenders · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

On Thu, Mar 03, 2016 at 01:47:00PM +0100, Martine Lenders wrote:
Show 13 quoted lines
> I'm not sure if this was already requested somewhere (a quick - but
> admittedly not thorough - search did not reveal anything in that
> direction), but I really miss an option to configure the prefixes generated
> by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase
> -i --autosquash`.
> 
> My reasoning is that in our project we use GitHub + Travis to test-build
> our pull requests, but we don't want to spam the CI server with builds that
> are just fixups to previous changes (which are uploaded so reviewers can
> track the changes to the original PR). Now, Travis has the option to not
> build a commit if there is the string `[ci skip]` in the commit message
> (sadly also not configurable) so it would be really great for my workflow
> if I could just add this string to the message generated by `--fixup`.

I am against the feature as you describe it, because it has the potential to break `git rebase --autosquash` with shared fixups if two people are using a different prefix.

However, it sounds like Travis will recognize "[ci skip]" anywhere in the commit message. Would a feature to allow autogenerated content in fixup/squash commit message bodies work?

In fact, this can already be achieved with a prepare-commit-msg hook like this (untested, but shows the principle):

-- >8 --
#!/bin/sh
case "$(head -n 1 "$1")" in
"fixup! "*|"squash! "*)
	cat >>"$1" <<-\EOF
	[ci skip]
	EOF
esac
Matthieu Moy· Mar 3, 2016, 13:58 UTC · re: John Keeping · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

John Keeping <john@keeping.me.uk> writes:
Show 22 quoted lines
> On Thu, Mar 03, 2016 at 01:47:00PM +0100, Martine Lenders wrote:
>> I'm not sure if this was already requested somewhere (a quick - but
>> admittedly not thorough - search did not reveal anything in that
>> direction), but I really miss an option to configure the prefixes generated
>> by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase
>> -i --autosquash`.
>> 
>> My reasoning is that in our project we use GitHub + Travis to test-build
>> our pull requests, but we don't want to spam the CI server with builds that
>> are just fixups to previous changes (which are uploaded so reviewers can
>> track the changes to the original PR). Now, Travis has the option to not
>> build a commit if there is the string `[ci skip]` in the commit message
>> (sadly also not configurable) so it would be really great for my workflow
>> if I could just add this string to the message generated by `--fixup`.
>
> I am against the feature as you describe it, because it has the
> potential to break `git rebase --autosquash` with shared fixups if two
> people are using a different prefix.
>
> However, it sounds like Travis will recognize "[ci skip]" anywhere in
> the commit message.  Would a feature to allow autogenerated content in
> fixup/squash commit message bodies work?

Or, alternatively: change the script used by Travis-CI to do something like

case "$(head -n 1 "$1")" in
"fixup! "*|"squash! "*)
	: do nothing
        ;;
*)
	launch_real_tests
esac
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Martine Lenders· Mar 3, 2016, 14:38 UTC · re: Matthieu Moy · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Hi Matthieu, We already do this :-). But sadly, this won't help: [ci skip] encourages Travis-CI to do nothing at all, while your proposed solution will at least require Travis to boot up a VM (or in case of a build matrix several VMs). In our case, including queueing this can take up to 1h.

Just in case you think I did not consider this: There is an issue on Travis' issue tracker [1], which is proposing to make this string configurable on their side, but sadly there was no reaction to that up until now.

Regards, Martine

[1] https://github.com/travis-ci/travis-ci/issues/4624
2016-03-03 14:58 GMT+01:00 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
Show 39 quoted lines
> John Keeping <john@keeping.me.uk> writes:
>
>> On Thu, Mar 03, 2016 at 01:47:00PM +0100, Martine Lenders wrote:
>>> I'm not sure if this was already requested somewhere (a quick - but
>>> admittedly not thorough - search did not reveal anything in that
>>> direction), but I really miss an option to configure the prefixes generated
>>> by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase
>>> -i --autosquash`.
>>>
>>> My reasoning is that in our project we use GitHub + Travis to test-build
>>> our pull requests, but we don't want to spam the CI server with builds that
>>> are just fixups to previous changes (which are uploaded so reviewers can
>>> track the changes to the original PR). Now, Travis has the option to not
>>> build a commit if there is the string `[ci skip]` in the commit message
>>> (sadly also not configurable) so it would be really great for my workflow
>>> if I could just add this string to the message generated by `--fixup`.
>>
>> I am against the feature as you describe it, because it has the
>> potential to break `git rebase --autosquash` with shared fixups if two
>> people are using a different prefix.
>>
>> However, it sounds like Travis will recognize "[ci skip]" anywhere in
>> the commit message.  Would a feature to allow autogenerated content in
>> fixup/squash commit message bodies work?
>
> Or, alternatively: change the script used by Travis-CI to do something
> like
>
> case "$(head -n 1 "$1")" in
> "fixup! "*|"squash! "*)
>         : do nothing
>         ;;
> *)
>         launch_real_tests
> esac
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
Matthieu Moy· Mar 3, 2016, 14:52 UTC · re: Martine Lenders · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

[ Please, don't top-post on this list ]
Martine Lenders <mlenders@riot-os.org> writes:
Show 6 quoted lines
> Hi Matthieu,
> We already do this :-). But sadly, this won't help: [ci skip]
> encourages Travis-CI to do nothing at all, while your proposed
> solution will at least require Travis to boot up a VM (or in case of a
> build matrix several VMs). In our case, including queueing this can
> take up to 1h.

Ah, indeed. Booting a VM just to execute "if fixup, do nothing" is a bit overkill ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Martine Lenders· Mar 3, 2016, 14:33 UTC · re: John Keeping · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Hi John, yes, it can be anywhere in the commit message and I already thought about using a hook for generating the commit message too, but the problem is then, that `git rebase` won't pair up the commit for squashing/fixing up with the original commit.

Maybe another approach could be to allow for a configuration of a string that is ignored when matching the commit messages in `git rebase`.

Regards, Martine

Am 03.03.2016 14:21 schrieb "John Keeping" <john@keeping.me.uk>:
Show 36 quoted lines
>
> On Thu, Mar 03, 2016 at 01:47:00PM +0100, Martine Lenders wrote:
> > I'm not sure if this was already requested somewhere (a quick - but
> > admittedly not thorough - search did not reveal anything in that
> > direction), but I really miss an option to configure the prefixes generated
> > by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase
> > -i --autosquash`.
> >
> > My reasoning is that in our project we use GitHub + Travis to test-build
> > our pull requests, but we don't want to spam the CI server with builds that
> > are just fixups to previous changes (which are uploaded so reviewers can
> > track the changes to the original PR). Now, Travis has the option to not
> > build a commit if there is the string `[ci skip]` in the commit message
> > (sadly also not configurable) so it would be really great for my workflow
> > if I could just add this string to the message generated by `--fixup`.
>
> I am against the feature as you describe it, because it has the
> potential to break `git rebase --autosquash` with shared fixups if two
> people are using a different prefix.
>
> However, it sounds like Travis will recognize "[ci skip]" anywhere in
> the commit message.  Would a feature to allow autogenerated content in
> fixup/squash commit message bodies work?
>
> In fact, this can already be achieved with a prepare-commit-msg hook
> like this (untested, but shows the principle):
>
> -- >8 --
> #!/bin/sh
> case "$(head -n 1 "$1")" in
> "fixup! "*|"squash! "*)
>         cat >>"$1" <<-\EOF
>
>         [ci skip]
>         EOF
> esac
John Keeping· Mar 3, 2016, 14:44 UTC · re: Martine Lenders · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

[please don't top post on this list]
On Thu, Mar 03, 2016 at 03:33:34PM +0100, Martine Lenders wrote:
> yes, it can be anywhere in the commit message and I already thought
> about using a hook for generating the commit message too, but the
> problem is then, that `git rebase` won't pair up the commit for
> squashing/fixing up with the original commit.

Huh? With the hook below you just run `git commit --fixup=...` as normal and it appends a "[ci skip]" line to the bottom of the commit message.

Show 37 quoted lines
> Am 03.03.2016 14:21 schrieb "John Keeping" <john@keeping.me.uk>:
> >
> > On Thu, Mar 03, 2016 at 01:47:00PM +0100, Martine Lenders wrote:
> > > I'm not sure if this was already requested somewhere (a quick - but
> > > admittedly not thorough - search did not reveal anything in that
> > > direction), but I really miss an option to configure the prefixes generated
> > > by `git commit (--fixup | --squash) <commit>` and picked up by `git rebase
> > > -i --autosquash`.
> > >
> > > My reasoning is that in our project we use GitHub + Travis to test-build
> > > our pull requests, but we don't want to spam the CI server with builds that
> > > are just fixups to previous changes (which are uploaded so reviewers can
> > > track the changes to the original PR). Now, Travis has the option to not
> > > build a commit if there is the string `[ci skip]` in the commit message
> > > (sadly also not configurable) so it would be really great for my workflow
> > > if I could just add this string to the message generated by `--fixup`.
> >
> > I am against the feature as you describe it, because it has the
> > potential to break `git rebase --autosquash` with shared fixups if two
> > people are using a different prefix.
> >
> > However, it sounds like Travis will recognize "[ci skip]" anywhere in
> > the commit message.  Would a feature to allow autogenerated content in
> > fixup/squash commit message bodies work?
> >
> > In fact, this can already be achieved with a prepare-commit-msg hook
> > like this (untested, but shows the principle):
> >
> > -- >8 --
> > #!/bin/sh
> > case "$(head -n 1 "$1")" in
> > "fixup! "*|"squash! "*)
> >         cat >>"$1" <<-\EOF
> >
> >         [ci skip]
> >         EOF
> > esac
Matthieu Moy· Mar 3, 2016, 15:59 UTC · re: Martine Lenders · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Martine Lenders <mlenders@riot-os.org> writes:
Show 5 quoted lines
> Hi John,
> yes, it can be anywhere in the commit message and I already thought
> about using a hook for generating the commit message too, but the
> problem is then, that `git rebase` won't pair up the commit for
> squashing/fixing up with the original commit.

It won't match if you put it in the subject line, but John's proposal is to put it at the bottom (i.e. in the body). This won't disturb "git rebase --autosquash".

> Maybe another approach could be to allow for a configuration of a
> string that is ignored when matching the commit messages in `git
> rebase`.
I wish I could write commit messages like
fixup! deadbeef: fix typo (foo -> bar)

So that the commit message contains both the instruction for "rebase --autosquash" and a quick explanation of what the commit is doing (as usual commit messages).

AFAIK, it's not possible currently but shouldn't be hard to implement.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Martine Lenders· Mar 3, 2016, 16:48 UTC · re: Matthieu Moy · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

> [ Please, don't top-post on this list ]
Sorry (*^.^*)
> It won't match if you put it in the subject line, but John's proposal is

to put it at the bottom (i.e. in the body). This won't disturb "git rebase --autosquash".

For some reason I did not even consider the bottom. Tried and it works! Thanks! I will integrate this into my workflow (and try to get other contributors to our project to do the same).

Show 13 quoted lines
>> Maybe another approach could be to allow for a configuration of a
>> string that is ignored when matching the commit messages in `git
>> rebase`.
>
> I wish I could write commit messages like
>
> fixup! deadbeef: fix typo (foo -> bar)
>
> So that the commit message contains both the instruction for "rebase
> --autosquash" and a quick explanation of what the commit is doing (as
> usual commit messages).
>
> AFAIK, it's not possible currently but shouldn't be hard to implement.

I would love that, too :-). This differs however from the original intent of my feature request. So maybe we finish this thread (since my John's proposal is 100% sufficient for me in that regard) and open a new one? How are the procedures for this on this list?

Regards, Martine

Matthieu Moy· Mar 3, 2016, 17:09 UTC · re: Martine Lenders · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Martine Lenders <mlenders@riot-os.org> writes:
>> [ Please, don't top-post on this list ]

... and as much as possible keep the "XYZ wrote:" line so that we know who wrote what ;-).

I wrote:
Show 14 quoted lines
>> I wish I could write commit messages like
>>
>> fixup! deadbeef: fix typo (foo -> bar)
>>
>> So that the commit message contains both the instruction for "rebase
>> --autosquash" and a quick explanation of what the commit is doing (as
>> usual commit messages).
>>
>> AFAIK, it's not possible currently but shouldn't be hard to implement.
>
> I would love that, too :-). This differs however from the original
> intent of my feature request. So maybe we finish this thread (since my
> John's proposal is 100% sufficient for me in that regard) and open a
> new one? How are the procedures for this on this list?

We don't have "procedure" for feature requests. It happens often that someone dreams aloud like I did above, and it's OK as long as "it shouldn't be hard to implement" is understood as "one day I should do it" and not "hey, you lazy devs, why don't you code that for me?" ;-).

But in general, people get more interested when a proposal has a patch attached.

I've added the idea here:
  https://git.wiki.kernel.org/index.php/SmallProjectsIdeas
(except I already changed my mind in the syntax)
I may get some students to work on this in May, or do it myself one day.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Junio C Hamano· Mar 3, 2016, 17:23 UTC · re: Matthieu Moy · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> We don't have "procedure" for feature requests. It happens often that
> someone dreams aloud like I did above, and it's OK as long as "it
> shouldn't be hard to implement" is understood as "one day I should do
> it" and not "hey, you lazy devs, why don't you code that for me?" ;-).
;-)
> I may get some students to work on this in May, or do it myself one day.

I envy teachers who can say "hey, code this for me if you want course credits".

Matthieu Moy· Mar 3, 2016, 17:34 UTC · re: Junio C Hamano · lore

Re: Feature request: Configurable prefixes for git commit --fixup and --squash

Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> I may get some students to work on this in May, or do it myself one day.
>
> I envy teachers who can say "hey, code this for me if you want
> course credits".

Well, in practice it's often still more work to supervise students than to do the work myself, but supervising students is what I'm paid for ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads