Commit Etiquette

git commit -m "considered impolite"

Ding! Ada’s Yes, the Ada Lovelace. phone buzzed, telling her about a new JIRA (Believe it or not, JIRA was around even then). ticket assigned to her. It seemed like a fairly straightforward ticket - just fix this tiny bug in one of their older libraries.

Hours later, Ada was banging her head against her keyboard. The code in this library had tentacles entangled everywhere. It felt like the butterfly effect applied to software - delete one parameter from one function, and another thread breaks under a particular race condition. But she was nothing if not persistent. A git blame on the line in question showed that no one had touched it literally in years. No surprises there. As a last bastion, she decided to look at the git logs for the two files side by side, hoping some past author left any breadcrumbs of how these two pieces interacted.

Ada face-desked. Abject horror flashed across her face, which she promptly buried in her hands in despair. The commit read: Add param to function so other thread doesn't crash, and she knew the author used “-m”.

Other urls found in this thread:

fixedpoint.xyz/blog/commit-etiquette/
github.com/torvalds/subsurface-for-dirk/blob/master/README#L92
youtube.com/watch?v=kzdugwr4Fgk
twitter.com/SFWRedditGifs

A lot of git tutorials instruct beginners to do something like the following:

git commit -m "my first commit"

I get it. If you don’t instruct them to use the m flag, you have to talk about gitconfig, EDITOR, and probably how to exit vim. That adds cognitive overhead to the task of “learning git” that may discourage initial committers. But - I would argue - it’s fundamental to using git well, and further that not talking about it reinforces bad practices.

Books are the best! I spend a great deal of my free time reading. Sci-Fi, fantasy, steam punk, the occasional non-fiction - I’ll read pretty much anything! I track all my reading on Goodreads, so you should become my friend on there if you’re not already. I also have a page that shows the books I’m currently reading (via Goodreads), which lives here.
Podcasts

I love podcasts! I feel like I’m always listening to a podcast in my spare time or during a commute. They’re great for news, learning and entertainment.

Some of my favorite podcasts, if you don’t mind my listing them alphabetically here, include: The Art of Product (and Giant Robots Smashing Into Other Giant Robots, which it grew out of), Ask Me Another, The Bike Shed, Code Newbie, Cortex, Developer Tea, Freakonomics, Free Agents, Hidden Brain, Reply All, The Tim Ferriss Show, Turing Incomplete, and Wait Wait Don’t Tell Me. There are lots of other podcasts that I listen to and love, so please don’t yell at me if I didn’t list yours here. Odds are good that I listen to it.

And, no, I haven’t listened to Serial. Yet. No spoilers!

Committing from the command line encourages conciseness over verbosity. If you make a typo or come up with a more clear phrasing, you probably won’t bother to whack the arrow key to go back and fix it. But commit messages should be verbose! Commit messages are not just a gratuitous step that we go through to appease git (although some people may think this). Writing commits - just like writing code - is fundamentally an exercise in communication. They will eventually be consumed by humans, and, when they are, they ought to provide value to the human.

With this in mind, I advocate the following practices when committing changes.

Keep It Small

Commit small, coherent sets of changes. This has nothing to do with how you write commit messages, and everything to do with how you stage your changes. “git add -p” is your friend here. Ensuring your diff is small and coherent will make the next practice far easier to follow.

Diversity in Tech

Another big passion of mine that I’ve been trying to involve myself in more lately. I’ve always been more of a “fly on the wall” in the tech diversity conversation. I’ve felt that as a cis, white male, I could easily shove my foot in my mouth. Plus, I didn’t have the same first-hand experiences with harassment or discrimination.

I am happy to report that I finally grew a spine and reached out to a coworker I knew was very involved with Women in Tech. We met for coffee and talked about increasing my involvement at the company. It went great, and I learned that there are many other cis, white males feeling just like me!

Commit messages should be structured as follows:

High-level summary of the changes. Keep it shortParagraphs upon paragraphs of _actual prose_, providing any relevantdetails about the changes. If you want to take advantage of`git shortlog` to have prettier logs, you should wrap the lines at 72characters.Relevant details can include: potential “gotchas”, reasonings behindchanges, motivations, relevant context for the changes, or anythingelse that may be helpful to some future developer spelunking throughthe commit history.These details should be much more of “why” behind the change, ratherthan a “what”. The "what" can be obtained by looking at the diff.

The main point of my writing this is to talk about the content of commit messages, rather than the format, but because of Reasons, there are two formatting nitpicks that I need to talk about. The high-level summary should not end in a period, because of git send-mail. There should, however, be an additional newline to separate the summary line from the detailed notes. I’m actually not sure why this is, but Linus has spoken, so maybe we’re all just too stupid to get it (he once actually said “if you still don’t like it, that’s OK: that’s why I’m boss. I simply know better than you do.” Ouch.).


Commit Showcases

I went looking through some repos to pull out some examples to illustrate my point. Here’s what I found.
The Good

Derek Prior (Rails):

Add `redirect_back` for safer referrer redirects`redirect_to :back` is a somewhat common pattern in Rails apps, but itis not completely safe. There are a number of circumstances where HTTPreferrer information is not available on the request. This happens oftenwith bot traffic and occasionally to user traffic depending on browsersecurity settings.When there is no referrer available on the request, `redirect_to :back`will raise `ActionController::RedirectBackError`, usually resulting inan application error.`redirect_back` takes a required `fallback_location` keyword argumentthat specifies the redirect when the referrer information is notavailable. This prevents 500 errors caused by`ActionController::RedirectBackError`.

Sean Griffin (Rails):

Allow `Relation#or` to accept a relation with different `references`Note that the two relations must still have the same `includes` values(which is the only time `references` actually does anything). It makessense for us to allow this, as `references` is called implicitly whenpassing a hash to `where`.Fixes #29411

Ariel Ben-Yehuda (Rust):

typeck::check::coercion - roll back failed unsizing type varsThis wraps unsizing coercions within an additional level of`commit_if_ok`, which rolls back type variables if the unsizing coercionfails. This prevents a large amount of type-variables from accumulatingwhile type-checking a large function, e.g. shaving 2GB off one of the4GB peaks in #36799.

Marcus Buffett (Rust):

Catch IOErrorIf config.toml doesn't exist, then an IOError will be raisedon the `with open(...)` line. Prior to e788fa7, this wascaught because the `except` clause didn't specify whatexceptions it caught, so both IOError and OSError werecaught

Alex Crichton (Rust):

rustc: Don't use DelimToken::None if possibleThis commit fixes a regression from #44601 where lowering attribute to HIR nowinvolves expanding interpolated tokens to their actual tokens. In that commitall interpolated tokens were surrounded with a `DelimToken::None` group oftokens, but this ended up causing regressions like #44730 where the variousattribute parsers in `syntax/attr.rs` weren't ready to cope with`DelimToken::None`. Instead of fixing the parser in `attr.rs` this commitinstead opts to just avoid the `DelimToken::None` in the first place, ensuringthat the token stream should look the same as it did before where possible.Closes #44730

Sean Griffin (Diesel):

Allow ad-hoc inserts using tuplesThis provides a more lightweight API for inserts that mirrors what ispossible with `.set` for updates. The implementation provided ensuresthat all elements within the tuple are valid for the same table, andthat there's no funkiness like sticking an upsert value in there.(Secret way to break Diesel -- It will totally allow you to stick a`Vec` in there, and will generate invalid SQL as a result. We should fixthat one eventually, but it's pretty low priority)One thing I would also like to allow is to allow mixing ad-hoc valuesand `Insertable` structs. (See 10374a5for rationale). I tried a naive approach where I moved the parens outfrom the `InsertValues` impl on tuples, and into `InsertStatement`, butthat breaks PG upsert, so I'll need to spend more time on it. I've leftthe test cases for that in place, but I will defer actually making thempass for a later PR in order to keep the PR size and scope reasonable.I expected to need more tests/compile-tests, but what's included herefelt like it pretty exhaustively tests everything.Fixes #789

Sean Griffin (Diesel):

rm `IntoInsertStatement`This gets rid of `IntoInsertStatement`, and turns `BatchInsertStatement`into the only visible type for constructing queries. In itsimplementations of `LoadDsl` and `ExecuteDsl`, it ends up constructing`InsertStatement` which is what actually performs the execution.The names are now super poor and misleading. The reason I've opted notto rename them in this commit is that I actually think I'm going to endup getting rid of `BatchInsertStatement` entirely, and only have`InsertStatement`. If we don't end up going that route, I'm going torename `InsertStatement` to `ExecutableInsertStatement` and rename`BatchInsertStatement` to just `InsertStatement`.Aside from simplifying our codebase, this change also makes sure thatall insert statements constructed will include the 0-row checking case.I think we can eventually just move this into the `QueryFragment` implby doing `SELECT returning_clause FROM table WHERE 1=0`. This would meanthe only thing we have to special case is SQLite batch insert.Fixes #797

Sean Griffin (Diesel):

Refactor `InsertValues` for tuplesThis changes the implementation of `InsertValues` on tuples to not careabout its interior type, and moves the SQLite special handling to`ColumnInsertValue` directly.The addition of the `Table` parameter on `InsertValues` is required forthe tuple implementation to enforce that all values are targeting thesame table.One side effect of this structure is that it will (eventually) allowarbitrary nesting of `Insertable` types. This is important for use caseslike rocket, where you will likely have a `user_id` field which comesfrom the session, but we want you to derive `Insertable` and `FromForm`on the same struct. This means we should be able to write code like thefollowing: #[derive(Insertable, FromForm)] #[table_name = "posts"] struct NewPost { title: String, body: String, } #[post("/posts", data = "")] fn create_post(data: NewPost, user: AuthenticatedUser, conn: DbConn) -> QueryResult { use schema::posts::dsl::*; let created = insert(&(user_id.eq(user.id), data)) .into(posts) .returning(id) .get_result::(&*conn)?; let url = format!("/posts/{}", created); Ok(Redirect::to(&url)) }This should also let us simplify the `default_values` code dramatically.

This commit message is fantastic! It has all the detail you could possibly want to know about the change, along with a code sample showing what the change is going for!

I find computers fascinating. They can also be scary, sometimes. But, there are some areas of computing that I’m more passionate about than others. I’m also well-aware there is a wide, wide world outside the realm of Computer Science. I love talking about software craftsmanship. I took a course on craftsmanship (based on Code Complete) during my sophomore year, and was a TA for the course for the next two years. If craftsmanship interests you, feel free to reach out! Nothing would make me happier.

Commits are meant to be read by humans. Provide lots of context when describing your changes. It’s like taking the time to eat well or get enough sleep - you may want to take shortcuts, but the benefits to doing it Right will pay off in major ways in the long term.

PS: In the original story, I played both roles. That is to say, I was both Ada and the Bad Committer. Sometimes, the reader of your breadcrumbs is Future You. So at the very least, be kind to Future You, and don’t commit with “-m”.

...

If you can't figure out the problem from these two statements you are probably retarded.

Where's the original post? I want to leave a friendly comment.

*commit

fixedpoint.xyz/blog/commit-etiquette/

LOL

Let's see if I can simplify some of these


remind idiots that not all http requests have a referrer

Don't just catch any exception


Add option to insert multiple rows at once, so you don't have to do it in a for loop.

get rid of some redundant insert function, but the insert functions could still be made less redundant.

This Sean Griffin guy sure likes to ramble.
On a side note, if you don't write sql manually, you are trusting these people not to fuck up you database, so don't do it.

Reminder that the less you agree with this mongoloid the less likely you are to find gainful employment in the software industry

Every time too. It's like these idiots think writing is easier than programming. Also gotta love that half?? of the blog is copy pasting from other people.

wow...

see lads? this is what we were missing all that time we blocked women from being able to work in programming with us.

I know for one I am glad we cut that shit out and now respect them as equals.

Christ, the irony in that last paragraph.

HARISH NO!!!

Faggotry like this is why there should be a writing license like how there is a driving license. It's astonishing how much this faggot can write without saying anything. Here is how it's done:

github.com/torvalds/subsurface-for-dirk/blob/master/README#L92

This shit is really common among programmers and computer scientists for some reason. Why is it these people can't just get to the fucking point and instead try to be all cutsey like they are trying to pass a creative writing class? This guy in another thread has done a great impression.

With that said, git commit -m does have its place for small self-contained commits. If I bump the version number, fix typos or do some other low-impact maintenance tasks there is no point in writing more than just one line of message. If people really want to know what the typo was or where the version number was bumped they can read the commit diff itself.

Pleb

Because wymyn codyrs might find it hard to understand or offensive otherwise.

Where do you find those? The only women in my office are the secretary and some part-time graphics designer girl, the rest of the dev team are all middle aged (45+) guys.

[Insert Silicon Valley company name here]

Then they both serviced their bulls later that night at the cuck party.

git commit -m "up"

git commit -m "PLEASE FUCK MY WIFE"

What a faggot

They don't actually code. They organize meetings and 'evangelize' and rat out anyone that is breaking the conditioning.

Because they're betas and approaching conversation nervously. That cutesy, meandering writing that they do is the same thing women do to blunt the edge of anything they're saying because they don't feel strong enough to be direct and assertive.

...

traps don't count

all women are vapid dumb cunts
they don't go into programming because they like it. they do it for the attention. in b4 "muh not all wymyn!!!" yes, ALL are the same.

Who else would you be you faggot.
Stop bringing it up every other second, I want my tech to work. Can you help with that or not? If you can, great. If all you can do is "evangelize" and tweet on social media and pose with a laptop because you have a vag or you have a special pronoun then fuck off.

Look on the bright side: you get paid more than if you had the same skill and a dick.
or you would if you were not some a guy pretending to be a grill

Tits or GTFO

...

this is how you fight diversity and strong womyn in tech

LOL

what did he mean by this

You definitely don’t sound insecure about your own motivations user

It's true though. That's what happens when you push women into these fields that were unable to organically generate their interest. Instead it's explained away as some society wide conspiracy that women don't like trucks, action figures and programming because men are oppressing them.

Consider the following; this conversation.
Most programmers learn as kids. They come websites like this. They try to join an IRC. That’s what I did, that’s what you probably did.
The difference is that the whole time, I hide the fact that I’m a woman by being considered a man by default. I quietly read line after line about how women are stupid and useless.
I just don’t really give a shit. Sane people would. Young people, especially girls, don’t really put up with that sort of thing. But you’ve got to see the irony in saying women are dumb/emotionally stunted because they don’t enjoy being subjected to pure hatred and being told to show their tits all the time. Women are discouraged from going into tech, but not by society at large. It’s by anons like you who continually spew the same drivel about women being /literally Hitler/ in the place where people first start dipping their toes in tech get started.

That reminds me: Tits or GTFO

yeah i remember back when i was learning programming. reading all those tutorials and documentation just littered with misogynist jokes every other line.

seriously. what the fuck are you talking about? is this a troll? so you joined some edgy women haters club IRC? that's your own fault. and stop posting images from your wymins can be smart too folder. it's cringy.

isn't even me. I'm just replying to you because the half of that which isn't a shitpost is correct. Women and men are not equal, though anyone who dares to publicly suggest that in modern culture is a nazi bigot.

and what the fuck are you talking about? it's the same with the IRC thing. when you go on 4/Holla Forums you have to know what to expect. it's an anonymous imageboard so it's obviously going to attract people with no filter or suppressed opinions whether right or wrong. go on reddit or something you vapid retard. no matter who you are people on here will tell you to kill yourself and hate you.

you're retarded and completely do not understand tits or gtfo. there is no reason to reveal your gender here, and if you do you will be flamed. just like how namefags get flamed. the only reason (an imageboard full of men) would care about if you are a woman is the prospect of sex. online there is no chance of sex with you, but you can still show us your tits.

now tits or gtfo cunt

tl;dr, see

user I don’t even think men and women are equal, I’m just saying to think women are useless at anything requiring logic is short sighted. I also think there is hostility in the same place a lot of people start out learning (i.e. different chans)
Do you disagree with these things?
Also checked.
Btw I don’t have a wymyns folder I’m saving these as I go, I’m not a turbo autist

That's where you're wrong
In closing, tits or GTFO

I agree that there is hostility on 4chan. What do you want me to say?

That doesn't matter anyway because anyone who learns to program from an imageboard is probably going to stay a NEET forever anyway. Also there SHOULD be hostility on imageboards. I pretty much come here just to argue/shitpost/insult people. That's kind of the point of an anonymous imageboard.

But since men and women aren’t the same, the point I’m making is that women are less inclined to be here. It is hostile. And that’s fine and it’s not bad, I’m merely hypothesizing why there’s not that many other women here or in tech in general. I’m not saying what’s right or wrong or good or bad. It is what it is.

What this nigger wrote.

Bitch what in the fuck are you even flapping about. You make it sound as if imageboards are the first place people go to learn anything. Are you fucking retarded.

that's a pretty shitty point. there are a lot of NEETs on here. would probably be good for women's chances of success that they don't come on here.
I disagree. I think there are a shit ton of womyn coder programs & diversity hires. I don't think we need to see more.

That’s not what I’m trying to say, but you all are seeming to be very angry at this point and I’m not so sure you actually want to discuss this anyway
Goodnight, I genuinely hope you don’t fall asleep with such hostile feelings bottled up because it will decay your soul. Praying you find peace as well. There’s no good things that come from blind anger

...

We're angry because you haven't posted tits

I don’t think I got destroyed. I made points about hostile environments towards women overlapping with the environments young kids starting to learn programming in. I hypothesized this contributes somewhat to the dearth of women in tech. I didn’t even say this was good or bad.
Then you raged out of emotion a few times
Kek

Also peace love what? I’m a Christian desu. I’m worried about you as a person I don’t give a shit about ‘“‘“‘“karma’”’”’”

just leave and pnever make a shitpost like this again

The reason is in chans usually there's no reason to say you've got tits unless you want free attention. In your post it's relevant so fair enough, but without tits or gtfo women would be almost as bad as namefags, who have a special place in hell just for them. Maybe not here, but on boards that actually get a few women.
Lose the mustache and there's literally nothing wrong with that.

Pussy is not tits you wench.

And yet, male anons get the same treatment from other anons, and that didn't discourage them. You see, being a woman, an insult crushes you because you have no innate drive for achievement. Your drive is for social status through feminine means: AKA status whoring. Being insulted because your code sucks is a heavy strike against your ego and your sense of your social status, and so you stop coding because you realize you won't get anywhere trying to status whore in the cold, hard world of Holla Forums.

But men? Men get insulted... and it drives us to be better. If someone says our code sucks, we don't go running crying to our hugboxes to help us feel better. You know what we do? We fix our fucking shit, because we realize that we have two choices: we can be a loser beta that achieves nothing, or we can pull up our boots and grow in knowledge and experience to the extent that we become the ones that insult the noob Holla Forumsies rather than the ones being insulted, because we're that good at what we do. As the Bible teaches: iron sharpens iron. Sharpening is a destructive process: bits of the iron are stripped away. You don't sharpen a sword by adding iron to it, you sharpen a sword by tearing away pieces from the end. In a similar manner, men must suffer in order to become better.

On average, you women aren't built for that sharpening process. You can't handle it without breaking down, like you are in this very thread. Hence, show your tits or GTFO. If your tits are nice enough, one of these good men here might take you for his wife to have many white children with.

women don't work because they don't get paid because they are universally despised as workers

every fucking time you niggers have to take the bait

It's almost as if it's all just a cynical marketing campaign.

Wait, what? What kind of kids go to imageboards to learn? I certainly did not, and I did not go to weird IRC chats either. I had my first introduction to programming as a teenager from magazines, and later learned how to properly program as an adult from actual books. I didn't even know about this site until it was mentioned during GamerGate.


That's a great one! I'm capping your post.

That's not true Tlat all. There's no such marketing drive.

this shit is so retarded.

b8

what IS text reflow?

We just don't know.

▢ tits
▢ GTFO

Choose one. Then back to the kitchen.

youtube.com/watch?v=kzdugwr4Fgk

...

...

please tell me what programming IRCs there are where you can talk shit about how retarded women are without getting banned.
please. (it doesn't exist)

That's a parody account, created to enforce your worldview, you fucking spastic.

*any comment that addresses the user as "he/him" instead of "them/they"*
They go apeshit over this.

Htiler /literary/ did nothing wrong.
Driving out foreign investment bankers speculating in local German currency, wrecking their financial system. Providing a realistic and achievable path to financial and social success for his country. Promoting strength, dignity, and a love for your fellow countryman amongst his people. Taking on the globalist jew and ejecting the parasites from his country.

We need another Hitler. Possibly, we do not yet deserve one.

Also tits or GTFO faggot

Socialism is not a realistic approach to any kind of success.

what the fuck am I reading.jpg

Look bitch, I don't care if you have a vagina, just code and shut up.

Tits or gtfo is no joke. Read for an explanation, and don't forget to check his beautiful trips.

I don't get the point of essay long commits. If you are writing more than 1 or 2 sentences, that extra text should either be made inta a comment / documentation, pull request body, or just culled entirely.

Wymyn coders can't possibly be expected to look at the code changes that are right there beside each commit. They need everything laid out for them in babyspeak paragraphs with an approving tone.

Only if they manage to learn git at all (instead of archiving code in zip or something). Otherwise it is irrelevant.

Nothing disgusts me more than someone who is so complacent that they have to make up problems of their own or for others. You've finally attained a point in your life where you can be comfortable and you sabotage yourself, making up fake oppression or goals either to impress others or masturbate your own ego. These people are truly the worst in my opinion, never content, always frauds, they need some serious introspection, it would benefit them so much more than constantly making up shit to "tackle" and figuring out the new trends of the in-crowd you just put on a pedestal who will be replaced in a year.

Hey John how's life?
Well it should be good but I've attacked my own psyche and I have to dye my hair blue today, next week I'll wash it out and cut it a certain style because blue will be considered offensive and trends will have changed, I desperately need to latch on to some movement to feel important because I can't be happy with myself without validation.

All these replies, /tech is truly dead.
I say again;

lol @ how Ada Lovelace barely did anything and still wrote more code than Holla Forums ever will

lol @ how Ada Lovelace barely did anything and still wrote more code than Holla Forums ever will

lol @ double post

lol @ double post>>803837

How horrifying

Imagine your call to fame being what's between your legs. Nobody knows what she actually did, they probably imagine she invented the precursor for the Macbook while drinking vintage Pumpkin Spice Latte or something.

>(((as a cis, white male)))
We need distributed, decentralized, parallelized Adolf Hitlers.

I just read the whole thing and the "Diversity in Tech" part is not in the article. Either the author removed it after he saw the comments or OP is full of shit. You are all getting riled up over nothing.

Ada Lovelace was a revolutionary. All the devs who copypaste from stackoverflow and call it programming owe her a big favor for blazing that trail.