Linus: please write good git commit messages
github.com
github.com
please do proper word-wrap and keep columns shorter than about 74 characters or so
How come word-wrapping is left as a task for humans here? Is there a technical/stylistic/cultural reason why lines can't be wrapped automatically to any desired width by the log presentation layer?
The optimal human-readable line length is something like 66 characters. It's much easier to quickly scan a log message that's 72 characters wide vs. one that is 200 characters wide.
This shell script wraps wide commit messages to the width of your console.
GIT_PAGER="fold -s -w`stty size | awk '{print $2}'` | less" git log $@"The optimal human-readable line length" isn't really something that exists, even if we make lots of assumptions about basic stuff like font size, avg word length, and color contrast.
Here's a quick study on the reading speed and comprehension of character line lengths (cl) between 35 and 95 for reference: http://psychology.wichita.edu/surl/usabilitynews/72/LineLeng...
- most efficient reading (speed/accuracy) at 95cl
- line length does not affect comprehension
But here's the head spinner:
- 60% _preferred_ either 35cl or 95cl
- 100% _least preferred_ 35cl (45%) or 95cl (55%)
Line length is an easy thing to assume everyone perceives the same way, but even given a consistent environment (definitely not a given in this age of increasingly diverse device dimensions) there's a wide range of preferences with little real impact on readability. Unless, of course, your assumptions about readability clash with the user's preferences or reading environment.
Put simply - make your life easy and reduce problems by just letting the user decide.
set editor="vim -c 'set tw=75 ft=mail noautoindent'"
The 'set tw=75' bit, sets the text width to 75 columns.So, wrap your paragraphs in plain-text email at some sensible column. Common convention suggests 72, because that allows for a few rounds of quoting before it passes 80.
Hard-wrapping paragraphs to a desired length in the original log allows humans to decide which lines should wrap and which ones shouldn't, without a pile of complexity similar to HTML, Markdown, or some other markup language.
soft-wrap:
- to allow the presentation layer to soft-wrap a line, just don't add a newline.
- for new paragraphs, just add two newlines as usual
- for indent sensitive code, diagrams, etc. add newlines where appropriate, taking care to not exceed 74 columns for any line. Everyone does this already.
+ tweak:
- in the presentation layer, soft-wrap all lines except those less than 74 characters long.
This isn't perfect for terminals less than 80 characters wide, in that the diagrams won't fit, but nobody uses narrow terminals, and Linus' scheme is even more broken for this case, so it's strictly better. It also allows one to easily distinguish diagrams from non diagrams by eyeballing the text flow. Best of all, it makes fewer assumptions about terminal width.
And what's stopping someone implementing this?
Most likely, not wanting to inflict such a syntax on git users, when the current approach works just fine.
But nothing stops someone from writing a patch with an off-by-default option for such a syntax, and proposing it for inclusion.
I'm not saying that's a good thing, mind you.
If we leave it up the masses to be on the honor system then the problem would be much larger. Everyone thinks they're awesome enough to bend the rules when they aren't. It always seems like the people who suck the most are the ones who believe they're the most skilled too. Why is that?
So yes, you are allowed to wander past them, ignore them, and use them as you believe most efficient.
GitHub's online editor has a default commit message along the lines of "Edited path/to/file", and I see a lot of pull requests with that message, and nothing else. That's about the most useless message possible, since it adds no information that isn't already implicit in the commit. It would be better to leave it blank and force users to at least write _something_.
Also, badges are done to death. Everyone's got badges these days - so much so they're like ads. Personally, I've developed a blind spot to most of them.
Besides, badges are for kids.
So really, what do you want them to say?
deep/magic: Commit changes even if not dirty.
Changesets are somewhat magical these days (obviously!); even if they are
not dirtied; they could end up being really, *really* bogus as far as
their on-disk status. The reason, as far as I can tell, is that in
deep/wizardry, we are being very liberal about our modifications to the
on-disk data structures without actually considering whether or not any
other owner of that structure is pending changes to commit. As a result,
we could end up heavily corrupting these structures if we're not careful.
I'm not altering the comments in the file because, frankly, the comments
imply that we should have already been doing this. I just changed the
code to match.
Fixes #4242. Finally! Time to go grab a beer. :3
Tests: +5 working
mad/deep/magic.py | 1 +
1 file changed, 1 insertion(+), 0 deletions(-)Small commits are fine and often don't warrant several lines. I've done that too.
It's often a fine line between a commit that's too big and too small. At the same time, just because a commit warrants a few sentences about it that doesn't necessarily mean it was too large. I don't want to keep being long winded here so I won't go into examples as I think we've all seen situations like what I'm talking about but I'd be happy to add an example later if necessary.
> If I need to write several paragraphs about
> the changes I'm making, it's definitely too
> large a commit.
careful, this is subjective, and a lot of people consider it best practice to commit in small chunks but rewrite local history right before we push to squash everything into one changeset for the issue. the idea being it keeps the master history high level which is more useful when looking at other-peoples-commits.http://tbaggery.com/2008/04/19/a-note-about-git-commit-messa...
74 chars is just awfully short...
ISSUE-1234: persist client-side display configuration to settings
and our issue tracking and code review software recognize issue numbers and hyperlink to the actual issue, with comments, reported-by, description, environment, replication steps, related changesets, code reviews, etc. pretty great especially considering multiple commits on the same issue which can't be rewritten into one commit because they've already been pushed. it also makes `git log --oneline` useful.Feature requests might require a whole branch, though. But in those cases, each individual commit in the branch would build towards the feature, and should reference the feature request.
But this comes up over and over and people should really start doing it! Especially on large and/or well known projects. This isn't just something that's useful to others but it can help you too! I'm a naturally long-winded person but the point isn't to write an essay, you just have to sum it up on line 1 give some context and details for the commit, then let us know who you are and how to get in touch.
Fortunately I've never had to revert Amy changes in my work (weird, right?) but if and when that day comes I'll be prepared. 99% of my work is done alone but I still write some decent commit messages. Who here remembers the date of your changes? Do you remember the exact state of the project at that time? Even if you remember that "well, the project was in X state Y commits ago" it'll only help you for about 5 commits max then you'll forget.
You need to know what you were doing and so do others. Even if you don't plan on working with others, I'd you're on GitHub with a public repo someone may unexpectedly like your project and want to see what's up with each commit. I recently had a project up on github that I thought was literally only useful for myself. It was a basic brochure style website for someone I made as a favor. Well it turns out someone here on HN wanted to learn to code, got in touch with me privately, then started exploring my github repos nth at guy actually used the stupid website I was building as a way to look at some code, tear it apart, and see how it worked. I was flattered and now I'm glad I write decent commit messages even if I'm only working with myself.
The point is, you'll never know when someone else or even yourself will need to look back at the logs and if the commit message is nothing but a date or something like "fixed the link" then you aren't reverting to a known past state - you're guessing.
I know a lot of Git newbies get scared after pressing return in the command line and nano or whatever built in text editor pops up. I didn't know how to end the commit message the first few times and save it or get back to the "normal" terminal so this may be part of why this happens but not a big part.
In any case, I feel strongly that this is an important thing that's overlooked and I'm glad it was brought up again. Hopefully people do it.