News for hackers. Stuff that matters.
Re:Atom – Git commit messages by icefox on Monday January 12, 2015 @10:42AM (#8874440)
I thought it was very meta amusing that the author was trying to tell users how to write commit messages when the number one rule of commit messages in my book is explaining WHY the commit exists. Why does this patch change this or do that. So it was amusing when he lists commit rules without explaining why they are rules. But I was saddened when I got to the end and missing from the list is 'explain why'.

Why did you 'Add feature...'? Why did you 'Move cursor to...'?

I did stuff // Increment i by 1

Why I did stuff // Increment i by 1 to not have a off by 1 bug

Re:Atom – Git commit messages by Morgawr on Monday January 12, 2015 @10:53AM (#8874505)
I see three different types of commits in my codebase, usually.

* The big fix: This is the commit which usually is too complex to be explained in a 72-characters message. Usually it refers to an issue number on the project's issue tracker, which in my case is Github.

* The medium fix: This is a commit whose "why" fits properly into 72 characters, i.e. "Add classes to validate user input only on Friday".

* The small/obvious fix: This is a very small commit, usually fixes obvious issues like CI builds, misspellings in doc files, missing semi-colons, etc etc.

In the last case, I find it appropriate to write the "how" rather than the "why" in the commit message, since the why is already obvious. i.e. "Add missing comma on object identifier".

Re:Atom – Git commit messages by xorcist on Monday January 12, 2015 @11:21AM (#8874703)
The "why" can live in the bug tracker, as a feature or fix may have several commits attributed to it.

For larger centralized projects, I have found a requirement on issue numbers in commit messages to work well. It makes a whole lot of management issues easier.

Re:Atom – Git commit messages by icefox on Monday January 12, 2015 @09:30PM (#8877773)
If issue numbers are the only requirement, is it okay if every commit only includes an issue number and no text at all? If not, why not? If they say something should it be the exact same thing as the issue title?
Re:Atom – Git commit messages by xorcist on Wednesday January 14, 2015 @12:59PM (#8887875)
IMHO, no. You should be able to read a commit log and understand what has been done. But if the issue titles are good enough they could absolutely be used as commit messages. Many issues leads to multiple commits however, so what you want for message is a description of the individual commit.
Re:Atom – Git commit messages by davexunit on Monday January 12, 2015 @10:53AM (#8874514)
>the number one rule of commit messages in my book is explaining WHY the commit exists

The commit message should say what changed, not why. Comments are for explaining why the code does what it does.

Good commit log: http://git.savannah.gnu.org/cgit/guix.git/commit/?id=fb519bd...

Re:Atom – Git commit messages by pjc50 on Monday January 12, 2015 @11:11AM (#8874644)
The diff shows you what changed. The commit message is a comment on the diff and absolutely should say what it's for.

This enables you to easily compile release notes, for example.

Re:Atom – Git commit messages by davexunit on Monday January 12, 2015 @11:21AM (#8874700)
Yes, it should say what it's for, but it shouldn't need to explain itself any further. Sorry if I didn't make that clear. For example, if someone refactored something, the commit log can simply say "Factorize foo", it need not explain why they were refactoring in the first place.
Re:Atom – Git commit messages by qznc on Monday January 12, 2015 @11:01AM (#8874571)
Comments tell why the code does what it does. Commit messages tell why the code does something different than before.

Example comment: i++; // because server starts counting at 0 (not 1)

Example commit: Our customer switched to bar (from foo), which starts counting at 0 instead

Re:Atom – Git commit messages by nirvdrum on Monday January 12, 2015 @11:56AM (#8874902)
That works as long as you're adding code. But what about when you're deleting code? I absolutely want to know why you've removed something.