What a good commit message looks like (2011)
github.com
github.com
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.
Software should help me, I shouldn't have to help it. Why doesn't git handle this formatting automatically? I shouldn't need to manually break lines for typographical (not paragraph) reasons.More seriously, it is quite hard to wrap text correctly after you submitted it. For example people add manual line breaks for structuring text and to separate things like quoted commands from the rest. It would be much more cumbersome to go back after a git commit to fix this, probably in multiple iterations until you get the intended presentation instead of just doing it right from the start.
Using a text editor to automatically embed line breaks doesn't fix the problem: embedding line breaks in text for formatting is wrong semantically. Hard line breaks should mean something. Now I can't reflow the text to display it on a web page in a normal font, because I can't be sure of which line breaks are meaningful, and which are formatting.
correctly in a plain text field?Text layout is a hard problem. It's why TEX (and its derivatives) is still so damned useful (and complicated).
Don't wrap lines with a four-space prefix (or whatever format is decided), wrap lines without one. Allow users to disable the wrapping if they prefer wrapped code. The prefix can be stripped at display time if you wish, so that code is left-aligned - actually, since the formatting isn't encoded in the log, only the semantics, users can configure the display as they please.
Possible handle lines beginning with - as lists and indent them correctly. If a message somehow breaks the format, do not accept it. This isn't TeX-level complexity.
When practical, of course.
In this case, git could simply give a "are you sure you want to commit with these long lines?" warning.
Added to Emacs in 1977.
How can the software guess whether a given line should be wrapped (text), should not be wrapped (code), should be wrap-indented (list item) or should be wrap-prefixed (quote block) when it's only given raw bytes assumed to be text without further information?
I'm not sure why this matters much?
If the code doesn't fit on the screen you're viewing it on, then it's not going to be convenient to read regardless of whether you wrap it or have a horizontal scroll.
>should be wrap-indented
When would you have an indented line that shouldn't be wrap-indented?
Because wrapped code is generally nonsensical.
> If the code doesn't fit on the screen you're viewing it on, then it's not going to be convenient to read
Inconvenient is one thing, nonsensical is an other.
> When would you have an indented line that shouldn't be wrap-indented?
That's noted right after, in the parens: list items.
This is not correct wrapping for a list item:
* this is a list
item
this is correct wrapping for a list item: * this is a list
item
If the display software does not do that (and I'm reasonably certain most would not) I'd much rather properly hard-wrap my text before committing it, that way I know that it will end up correctly wrapped and actually readable.Not really? It's probably slightly more awkward to read than scrolling, but then, the solution is to read code on an appropriately sized screen in the first place.
And incidentally, truncated code definitely is nonsensical.
>List items.
They can be handled as you mention, but it's hardly the worst thing in the world if they're not.
And if you really care about formatting this much, you should use a format that encodes it properly (e.g. Markdown) instead of producing the text equivalent of a PDF.
Yes really.
> but then, the solution is to read code on an appropriately sized screen in the first place.
That's not a solution to anything.
> And incidentally, truncated code definitely is nonsensical.
Truncated code is visibly truncated, not nonsensical garbage right next to actual code.
> They can be handled as you mention
And the software knows what a list item is… how?
> it's hardly the worst thing in the world if they're not.
One more fantastic non-solution to listed problems, we're definitely going places.
> And if you really care about formatting this much, you should use a format that encodes it properly (e.g. Markdown) instead of producing the text equivalent of a PDF.
So you're saying git should embed a markdown renderer and text layout engine?
I'm not sure what scenario you're imagining where you absolutely have to read code in commit messages on an unreasonably narrow screen, and you can't wait until you have an appropriate machine. But if a scenario occurred where that were important, I'm sure you'd manage to read some wrapped code, it's not that hard.
>Truncated code is visibly truncated
Unless it's not, because there's ` + someExtraStuff` just off the end.
>So you're saying git should embed a markdown renderer and text layout engine?
If you really want pristinely formatted commit messages that badly then yes.
Mate, I already have pristinely formatted commit messages, because I format them as I desire.
You are the person telling me I shouldn't be formatting my messages and a nebulous "software" ought do that, the burden's on you to give them the tools which yield the same pristinely formatted output I already achieve without a formatted input.
This does not mean that the format needs to be Markdown (which includes embedded HTML, so obviously not Markdown), or that all software needs a Markdown renderer. I'm not sure why you'd conclude that.
It would be interesting to have a way to indicate a formatting style when composing a log message though; for instance, a way to indicate that a log contains Markdown code.
That said, it is arguable if we must do that step forward from the development perspective. These tools already solved real issues, and now we discuss preferences. Personally, I'm fine with terminal on the left and wrap-capable editor on the right. It's not "to support software", I really like it more.
For instance, if you're editing a document and write a long sentence, that spreads over 3-4 lines. You then take a scalpel to it to make it more concise, so that it fits on a line or 2. Emacs won't reflow it automatically, you can manually get it to reflow (M-q by default), but its not the behaviors you expect from say a word processing program. Same exists if you insert new text.
TLDR: all auto-fill mode does is insert new lines when you reach the line length limit.
Vim also has an auto-format feature, which can be enabled with `:set formatoptions+=a` and will make paragraph editing behave a bit more like, say, a word processing program, but the Vim help file cautions that formatting long paragraphs or paragraphs with complicated indentation can get slow. I haven't really used the auto-format feature myself, so I can't comment on how slow it actually seems to be in practice.
How I understand that: If you can't format your commit messages, how can you be considered reliable to format your code how the company defines it?
I'm sure someone can write a patch for git commit comments to enforce a 74 character limit on line width with CR\LF indiscriminately or separate them "smarter" by breaking words at 0020 after it crosses the 74 character width limit. But that's besides the point.
Patient: "It hurts when I move my arm".
Doctor: Don't move your arm.
It's absurd to take a principled stand against software alleviating development pain.
lolwut? Is anyone saying: "don't write a commit-msg hook!" or "how dare you configure a programmer's editor to wrap at a fixed width?"
I see a lot of what boils down to: "it's not my problem how you and your teams go about following a formatting standard that's popular but not mandatory."
Tell that to the plentiful amount of businesses and software development groups that enforcing good coding style is wasteful. I'll wait.
This is a classic form of non sequitur. This kind of logic is the driver behind "If you can't be arsed to dress up in a suit and tie then you don't really care about your job" and "If you don't support our troops you are a Bad Person and you should leave the country".
Empirically, no one has shown formatting git commit messages to be predictive of code quality whatsoever. Sure, good engineers tend toward longer, more descriptive commits, but whether or not they follow proper text wrapping is totally beside the point. Poor code formatting is indicative of lack of skill, poor commit message formatting is indicative of a lack of knowledge of this one web page that most people have probably never seen.
---
A good commit message looks like this:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things in more detail, possibly giving some background about the issue being fixed, etc etc.
The body of the commit message can be several paragraphs, and please do proper word-wrap and keep columns shorter than about 74 characters or so. That way "git log" will show things nicely even when it's indented.
Reported-by: whoever-reported-it
Signed-off-by: Your Name <youremail@yourhost.com>
where that header line really should be meaningful, and really should be just one line. That header line is what is shown by tools like gitk and shortlog, and should summarize the change in one readable line of text, independently of the longer explanation.
Validation of email addresses now sends a test email to the user, instead of the old regex that never worked.
This style does not work for all kinds of changes, but when it works, it creates a nice history of how the functionality of the system grew...I'd use something like "Improve email validation" or "email: send a test email as validation" or such.
The body is where you can describe previous behaviour and give more details.
Validation of email addresses now sends a test email to the user, instead of the old regex that never worked.
> Send test email to user for email address validation > > This change was done because the old regex never worked; see also {link} and {link} for more information.
as an example. Ideally the header also contains a hint to the module the change was done in, etc. The linux kernel commits take this to (what comes across to me as) the highest levels.
A point of contention seems to be the choice of the imperative, at least for the subject line. While I'm really used to it, both when reading and writing, many people seem to strongly prefer past tense ("Fixed bug …" instead of "Fix bug …").
I don't care if this was easy or hard or the bug was non-obvious or if you used a weird trick.
I do care what the change does: fixes a race condition, adds a new file mode etc. Those changes matter at the time (what's new in the code?) and when looking backwards (ah, here's where that new file mode was added, let's see what was going on then).
If the project uses past tense, use it. If you want to change the convention, that's okay too, but everyone has to change.
It's exactly the same issue as coding style. If you can look at code or commit messages and figure out who wrote it based purely on style/formatting, you're doing it wrong (or rather: the person using the inconsistent style/format is).
This allows me to keep the commit line short and to see the commits history related to the resolution of a bug or feature.
When using Gitlab, Bitbucket or Github the issues and the commits are cross-linked (example: [0]).
[0] https://bitbucket.org/binarno/imebra/issues/162/ [1] https://imebra.com/wp-content/uploads/documentation/html/sop...
// cleans responses
function zrgfy(response){
...
}
should be something like: function cleanResponse(response){
...
}All of those were good choices when they were new, and suboptimal choices when the next better solution came along.
Last I worked with used CVS and always talked about switching to SVN, but never did.
We also use this convention with gitflow, so our branches are named eg, feature/PROJ-1234-added-new-ui or bug/PROJ-2345-fix-new-ui. This also lets JIRA find and link them, and makes pull requests get the ticket number in their title by default as well (since its based on branch name).
The last bit is just a short human-readable thing to make branches easier to look at and find, because the initial way we started using gitflow:
feature/
feature/PROJ-2286
feature/PROJ-2352
feature/PROJ-2367
feature/PROJ-2382
feature/PROJ-2385
bug/
bug/PROJ-2240
bug/PROJ-2323
bug/PROJ-2393
is completely unintelligible.I understand that the Signed-off-by line is equivalent to a CLA, right?
And signed-off-by is essentially a shorthand for agreement to this document: http://developercertificate.org/
Signed-off-by is fallout from the SCO lawsuit. It has nothing to do with agreeing to any sort of CLA; it's just another way to confirm that the code was written by the person in Signed-off-by, or that the person in Signed-off-by thinks it was created under appropriate open source conditions (e.g. the company who paid the developer to write it is okay with it being released).
In regards to commit ethos, I'm not sure I agree with all of the statements made. To me, something simple/concise, that others will understand, but not lacking in key info, is much better than several paragraphs explaining the same thing.
Trying to get something to run on Heroku involved making lots of small changes just to get things to run on the server the same as on my dev machine.
When you do that 10 or 20 times the commit message become somewhat meaningless.
https://gerrit-review.googlesource.com/Documentation/user-si...
For example:
"I fixed the button issue on the homepage. Still, need to center the title."
would be better written as:
"fixes button issue on homepage"
Always think about what that commit does to the codebase. This is obviously for single-line commits. I suppose it would be okay to "dear diary" in the commit body. You can provide rationality or context in the commit body.
Fix button issue on homepage
This allows the title to be centered,
as the button will no longer collide with it.
Then, in a subsequent commit, center the title and put a reference to this one if you feel it's important, like so: Center the title on the homepage
It wasn't previously because it would collide with the button,
but that was fixed in f00b1f.I once wrote "commit". A fellow coworker still makes fun of me for that, joking of course.
path dependency is hell of a drug.