I read his message. He didn't seem grumpy or frustrated to me; just encouraging folks to use a certain style that's already in wide use, for reduced noise and better consistency.
post
And here it is in the kernel contribution documentation.
Simple example:
- bad:
Added foo interface. - good: Add foo interface.
So the commit says what applying the patch will do, not what you worked on.
good: Add foo interface.
Another commit style is summarizing what a commit does. In this case it would be someting like:
Adds foo interface.
I think this style is more in line with auditing code.
This indicative mood is something I would send back for correction or correct myself where I am the maintainer. However I understand that although this is pretty consistent through FOSS, it is not a settled matter especially in corpo-land. Most important is that it is consistent within a project. See many differing views here on Stackoverflow, noting the most popular answer though is imperative as Linus requests.
This has been the recommendation and the way to do it for decades everywhere I've been too.
There are much smaller projects that ask for more from commits/merge messages. This is a normal ask
Linus Torvalds: creator of Linux and Git, and hero to all English teachers everywhere!
So, uh, I have a colleague who studied linguistics, and when I explained to her that we write commit messages like that, her reaction was basically: What the fuck, why?
My explanation wasn't as sharp, as I didn't call it "imperative" but rather just "infinitive", which got me the immediate backlash that it's not a sentence then, so why do you put a dot behind it?
She did accept my descriptivist excuses explanation that we write it that way, because it's terser, but I know it didn't sit well with her.
Will need to see what her reaction is to commanding the repo. 😅
you put a dot after commit msg?
Yup. Commit messages are often shown in truncated form, which is when the dot helps to know whether you're seeing the whole message or not.
Well, and every so often, I'll use the commit message to document why a change was made, which requires multiple sentences. Then the dot just serves its usual purpose of separating sentences.
Real developer's commit messages are all “Oops”.
depending on the time of day my commits range from war and peace to 'jfc here is just the message "yeah" for the next twenty commits because the client keeps requesting stupid ass decisions".
Linus Torvalds expressed frustration over the use of passive voice in merge commit messages, preferring active and imperative language instead.
Things To Care About, vol 147, 2nd edition
I like good commit messages that use less words but still give the full picture. If something hacky was done then a comment is better. I like mine with imperative voice since it avoids writing a prose.
"Fix a bug where when doing x then y happens"
"Add setting to control x"
I really don’t like starting with “fix.” You can just describe it without saying “fix” most times.
- Fix
Strings containing whitespace - Escape
Strings containing whitespace inCSVExporter
I always thought of the "how" being better explained by the code itself where you can see string.replace(" ", "\ ") as the actual fix while the message says the "why".
I would still have "Fix a bug where strings containing whitespace break CSVExporter" as my go to message.
I guess our viewpoints are different based whether we want the commit messages to represent tasks or changes. They both have their uses of course. Looking at changes to a file to know what people have done to it is better with a "changes" type message but looking at the history to check "did we actually complete this or was it just marked as completed in the issue tracker?" is better with a task based message.
Task management where every issue is put on a ticket and tracked would my type of messages obsolete but at my current company theyre very useful.
Love a good commit message. I wish I could say what we perceive as “good” is instead thought to be “normal”, but we aren’t there yet I guess.
If the word “imperative mood” is hard to grasp, this is what I do. I just finish this sentence in less than 50 - 75 words, length depending on consensus.
This commit will …
Add more details in the body if needed.
This sort of style extends to PRs/MRs as well.
This PR/MR will …
Upd
Fix
Upd
Fuck
Updated file1
Fuck
Fix
Updated file2
Merge remote-tracking branch other-user1-feature
Fix after merge
Upd
Revert "Merge remote-tracking branch other-user1-feature"
Revert "Revert "Merge remote-tracking branch other-user1-feature""
Updates & fixes -> I personally made updates with my bare hands and then also actively fixed some broken things also with my bare hands
You head him boys! Users of passive voice should be puched in the face!
When I do commit, I write up the title of what I did, and describe it, and then use periods for related commits. Just easier.
all 50 comments