threads / discuss / 31994

Wrap commit messages on `git commit -m`

Subject: Wrap commit messages on `git commit -m`

## tl;dr

11 messages between Nov 1, 2012 and Nov 4, 2012.

replies: 10people: 9as markdown or json

Ramkumar Ramachandra· Nov 1, 2012, 16:07 UTC · lore
Hi,

Some of my colleagues are lazy to fire up an editor and write proper commit messages- they often write one-liners using `git commit -m`. However, that line turns out to be longer than 72 characters, and the resulting `git log` output is ugly. So, I was wondering if it would be a good idea to wrap these one-liners to 72 characters automatically.

Thanks.
Ram
Lars Gullik Bjønnes· Nov 1, 2012, 16:29 UTC · re: Ramkumar Ramachandra · lore

Re: Wrap commit messages on `git commit -m`

Ramkumar Ramachandra <artagnon@gmail.com> writes:
| Hi,
>
| Some of my colleagues are lazy to fire up an editor and write proper
| commit messages- they often write one-liners using `git commit -m`.
| However, that line turns out to be longer than 72 characters, and the
| resulting `git log` output is ugly.  So, I was wondering if it would
| be a good idea to wrap these one-liners to 72 characters
| automatically.
git commit -m 'foo: fix this problem

This problem is fixed by doing foo, bar and baz.

Signed-off-by: me
'
works.
-- 
	Lgb
Kevin· Nov 1, 2012, 21:52 UTC · re: Lars Gullik Bjønnes · lore

Re: Wrap commit messages on `git commit -m`

As I see it, the problem is not the possibility to add new lines, but colleagues being too lazy to add them.

On Thu, Nov 1, 2012 at 5:29 PM, Lars Gullik Bjønnes <larsbj@gullik.org> wrote:
Show 28 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
> | Hi,
>>
> | Some of my colleagues are lazy to fire up an editor and write proper
> | commit messages- they often write one-liners using `git commit -m`.
> | However, that line turns out to be longer than 72 characters, and the
> | resulting `git log` output is ugly.  So, I was wondering if it would
> | be a good idea to wrap these one-liners to 72 characters
> | automatically.
>
> git commit -m 'foo: fix this problem
>
> This problem is fixed by doing foo,
> bar and baz.
>
> Signed-off-by: me
> '
>
> works.
>
> --
>         Lgb
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Nieder· Nov 1, 2012, 22:12 UTC · re: Kevin · lore

Re: Wrap commit messages on `git commit -m`

Kevin wrote:
> As I see it, the problem is not the possibility to add new lines, but
> colleagues being too lazy to add them.

I suspect the underlying problem is that we make it too hard to tell git which text editor to run.

Ram, what platform do your colleagues use?

Thanks, Jonathan

Ramkumar Ramachandra· Nov 2, 2012, 19:37 UTC · re: Jonathan Nieder · lore

Re: Wrap commit messages on `git commit -m`

Jonathan Nieder wrote:
Show 7 quoted lines
> Kevin wrote:
>
>> As I see it, the problem is not the possibility to add new lines, but
>> colleagues being too lazy to add them.
>
> I suspect the underlying problem is that we make it too hard to tell
> git which text editor to run.
Don't we just use $EDITOR?
> Ram, what platform do your colleagues use?
Red Hat Enterprise Linux 5.
Ram
Jonathan Nieder· Nov 3, 2012, 06:38 UTC · re: Ramkumar Ramachandra · lore

Re: Wrap commit messages on `git commit -m`

Ramkumar Ramachandra wrote:
> Jonathan Nieder wrote:
>> Ram, what platform do your colleagues use?
>
> Red Hat Enterprise Linux 5.
Oh, ok.  In that case I blame habit.

I think the best option you have is to just complain to your colleagues about the long lines. Then they would get a chance to explore what the UI currently offers and to complain to this list (perhaps via you :)) about missing features that would make their work easier.

To put it another way: I don't see yet how a hypothetical "git commit --wrap-lines -m 'long message'" would make life easier than just running "git commit" and entering the message using $EDITOR. There's probably a UI or documentation bug lurking somewhere, so thanks for thinking about these things.

Regards, Jonathan

David Aguilar· Nov 3, 2012, 07:41 UTC · re: Jonathan Nieder · lore

Re: Wrap commit messages on `git commit -m`

On Fri, Nov 2, 2012 at 11:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 23 quoted lines
> Ramkumar Ramachandra wrote:
>> Jonathan Nieder wrote:
>
>>> Ram, what platform do your colleagues use?
>>
>> Red Hat Enterprise Linux 5.
>
> Oh, ok.  In that case I blame habit.
>
> I think the best option you have is to just complain to your
> colleagues about the long lines.  Then they would get a chance to
> explore what the UI currently offers and to complain to this list
> (perhaps via you :)) about missing features that would make their work
> easier.
>
> To put it another way: I don't see yet how a hypothetical "git commit
> --wrap-lines -m 'long message'" would make life easier than just
> running "git commit" and entering the message using $EDITOR.  There's
> probably a UI or documentation bug lurking somewhere, so thanks for
> thinking about these things.
>
> Regards,
> Jonathan

If your colleagues do not mind using a GUI then git-cola might help them form better commit messages.

It auto-wraps long lines and enforces a very clear distinction between the one-line summary and extended description.

-- 
David
Phil Hord· Nov 3, 2012, 18:51 UTC · re: David Aguilar · lore

Re: Wrap commit messages on `git commit -m`

On Sat, Nov 3, 2012 at 3:41 AM, David Aguilar <davvid@gmail.com> wrote:
Show 30 quoted lines
> On Fri, Nov 2, 2012 at 11:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Ramkumar Ramachandra wrote:
>>> Jonathan Nieder wrote:
>>
>>>> Ram, what platform do your colleagues use?
>>>
>>> Red Hat Enterprise Linux 5.
>>
>> Oh, ok.  In that case I blame habit.
>>
>> I think the best option you have is to just complain to your
>> colleagues about the long lines.  Then they would get a chance to
>> explore what the UI currently offers and to complain to this list
>> (perhaps via you :)) about missing features that would make their work
>> easier.
>>
>> To put it another way: I don't see yet how a hypothetical "git commit
>> --wrap-lines -m 'long message'" would make life easier than just
>> running "git commit" and entering the message using $EDITOR.  There's
>> probably a UI or documentation bug lurking somewhere, so thanks for
>> thinking about these things.
>>
>> Regards,
>> Jonathan
>
> If your colleagues do not mind using a GUI then git-cola
> might help them form better commit messages.
>
> It auto-wraps long lines and enforces a very clear distinction
> between the one-line summary and extended description.

vim also does this nicely with syntax highlighting turned on, though I do not know how this feature is triggered.

Specifically, it wraps all lines at 72 characters; it colors line 1 yellow out to 50 characters and white after that; and it colors any text on line 2 with a red background (should be empty).

Phil
Tay Ray Chuan· Nov 4, 2012, 07:27 UTC · re: Lars Gullik Bjønnes · lore

Re: Wrap commit messages on `git commit -m`

On Thu, Nov 1, 2012 at 11:29 AM, Lars Gullik Bjønnes <larsbj@gullik.org> wrote:
Show 20 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
> | Hi,
>>
> | Some of my colleagues are lazy to fire up an editor and write proper
> | commit messages- they often write one-liners using `git commit -m`.
> | However, that line turns out to be longer than 72 characters, and the
> | resulting `git log` output is ugly.  So, I was wondering if it would
> | be a good idea to wrap these one-liners to 72 characters
> | automatically.
>
> git commit -m 'foo: fix this problem
>
> This problem is fixed by doing foo,
> bar and baz.
>
> Signed-off-by: me
> '
>
> works.

Perhaps a deeper issue is that the implicit email format (subject-body) for commit messages, is, well, implicit. New users of git who type git-commit -m '...' isn't going to know that those few characters will all be lumped on a "subject" line, forever screwing themselves when they review the output of git-log, git-rebase --interactive, etc. (can't remember off the top of my head if git-format-patch would chop off long subjects and move it to the body), which may be a significant period of time (and thus commits) later.

While I don't have any ideas on how to improve on this, hopefully this gets recognized as an issue in the first place.

-- 
Cheers,
Ray Chuan
Thomas Adam· Nov 1, 2012, 18:12 UTC · re: Ramkumar Ramachandra · lore

Re: Wrap commit messages on `git commit -m`

Hi,
On 1 November 2012 16:07, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
Show 9 quoted lines
>
> Hi,
>
> Some of my colleagues are lazy to fire up an editor and write proper
> commit messages- they often write one-liners using `git commit -m`.
> However, that line turns out to be longer than 72 characters, and the
> resulting `git log` output is ugly.  So, I was wondering if it would
> be a good idea to wrap these one-liners to 72 characters
> automatically.
Can't you do this already?  From "git-log(1)":
 %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w
option of git-shortlog(1).
-- Thomas Adam
James Nylen· Nov 1, 2012, 21:10 UTC · re: Thomas Adam · lore

Re: Wrap commit messages on `git commit -m`

On Thu, Nov 1, 2012 at 2:12 PM, Thomas Adam <thomas@xteddy.org> wrote:
Show 15 quoted lines
> Hi,
>
> On 1 November 2012 16:07, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
>>
>> Hi,
>>
>> Some of my colleagues are lazy to fire up an editor and write proper
>> commit messages- they often write one-liners using `git commit -m`.
>> However, that line turns out to be longer than 72 characters, and the
>> resulting `git log` output is ugly.  So, I was wondering if it would
>> be a good idea to wrap these one-liners to 72 characters
>> automatically.
>
> Can't you do this already?  From "git-log(1)":
>

I think he's talking about git-commit wrapping the message as it is being committed, instead of git-log doing the wrapping as it is being displayed.

I personally would rather see git-commit refuse to accept messages wider than 72 characters.

← back to recent threads