News for hackers. Stuff that matters.
Re:Git Things by mfrw on Monday January 01, 2024 @04:29AM (#38830669)
> Second, not every change needs a great commit message. If a change is really minor, I would say minor is an okay commit message!

I want to slightly disagree on this for folks who are early on in career e.g me; I think there is a lot of value in learning to communicate precisely and having a habit of writing good commit message has certainly improved my skills, both verbal and written.

Even though, this activity appears futile for a minor change; it might help to improve other skills :)

Re:Git Things by anordal on Monday January 01, 2024 @05:51AM (#38830991)
I also want to slightly disagree, or rather state a minimum:

The most important part of a commit message is the context.

Good enough commit log:

    utils: Minor
    drivers: Fix
    assets: Update
    docs: Typo
Hopeless commit log:

    Minor
    Fix
    Update
    Typo
Context should answer the "what". Think of it as the one word you tell a new conversation participant to let them realize what you are talking about.
Re:Git Things by mcluck on Monday January 01, 2024 @06:52AM (#38831223)
Totally disagree on

    drivers: Fix
Let's say your fix causes issues later. When I read the commit message, I want to understand what you were trying to fix so I don't accidentally re-introduce the problem when I fix your fix
Re:Git Things by quickthrower2 on Monday January 01, 2024 @07:12AM (#38831304)
For that you have external bug tracking systems. Although I tend to have a short summary and mention the ticket number. Therefore the comment stands alone but also has that extra detail outside.
Re:Git Things by chris_wot on Monday January 01, 2024 @09:03AM (#38831819)
Yeah, don’t do that. The LibreOffice code is littered with commits from bug tracking systems we no longer have access to or don’t exist any more.

Explain the issue, and by all means mention the bug number, but you must explain the issue you are dealing with.

Re:Git Things by mcny on Monday January 01, 2024 @10:01AM (#38832203)
At $work, I noticed someone was regularly committing with just a dot . as a commit message. The problem was that this repo does not have automatic scss => css for whatever reason and there's a designated person who untangles the mess and fixes people's bad scss and regenerates the css files (among other duties). After about a few dozen times, they just started putting a dot as a commit message.

Point is bad commit messages are sometimes a symptom to a larger problem and as with this vendor it is often a process problem, not an individual developer problem. In my opinion, the main problem here is that management simply doesn't care she it doesn't empower leads and developers who should care.

Re:Git Things by ZealousIdeal on Monday January 01, 2024 @12:51PM (#38833648)
I agree such patterns are indicative of systemic issues. In my experiences, those process issues emit their own structured behavioral patterns. In your example, the "." commit is now a convention that indicates a specific process happened. I am not certain what the costs of fixing the root problem are, though I'd anticipate they could be expensive and difficult at this point given the time commitment to restructure the repo and automate the scss=>css. Whereas the expense of an esoteric "." commit appears relatively cheap given the need of a human to untangle the mess which cannot be automated away (without a redesign).
Re:Git Things by quickthrower2 on Monday January 01, 2024 @06:50PM (#38836434)
That is what I meant by:

> Although I tend to have a short summary and mention the ticket number.

So for example

    XJ-8883 - Ensure DB connections are closed sooner in main pool
Re:Git Things by anordal on Monday January 01, 2024 @10:10AM (#38832262)
Do you totally disagree that this is the minimum? I'm only saying that the context is the minimum. I refuse to disagree with you about things I'm not saying.
Re:Git Things by mcluck on Monday January 01, 2024 @05:02PM (#38835738)
I'm disagreeing to both points. That's not an acceptable commit message at all. I don't need to know you were working on drivers, that's obvious from the files you were working on. The minimum for a commit message should be the why, not the what
Re:Git Things by hmeh on Monday January 01, 2024 @09:14AM (#38831897)
There’s another way that feels totally unnatural at first, but puts the subject (the most important part) of the commit message first. It makes the commit about the change and the code, rather than the author. This is how we do it in all of our projects. I fought it at first, but I was wrong and it’s a lot better.

Example:

EntityStore build method records the specifier argument when given

Article about it: https://github.com/aaronjensen/software-development/blob/mas...

Re:Git Things by karlshea on Monday January 01, 2024 @04:55AM (#38830774)
You’re totally right, if it’s that minor then you can type in a word or two to describe it like “spacing”.
Re:Git Things by Izkata on Monday January 01, 2024 @05:17AM (#38830878)
Even something that simple falls into what vs why: You can tell it was spacing from the diff, so the commit message should be "linting" or "alignment" or something similarly more meaningful.
Re:Git Things by quickthrower2 on Monday January 01, 2024 @07:13AM (#38831309)
The diff may not be visible. The person might be doing a complicated cherry pick or merge and scrolling through hundreds of commits. If the message explains it, it saves them digging in.

My analogy is your bookshelf books still need jackets!

Re:Git Things by Vinnl on Monday January 01, 2024 @09:03AM (#38831820)
First line is for what, the rest of the commit message is for the why - if needed.

As for "spacing", you can probably tell the why from the diff as well. The "what", however, tells you whether it's even worth opening the diff.

Re:Git Things by mytailorisrich on Monday January 01, 2024 @07:01AM (#38831262)
Usually, in more structured professional environments every commit must link back to a change request, which them provides context.

But yes, even minor changes should have a descriptive commit message that summarises the change in order to make commit history useful.

Now, when the code itself needs an explanation then that should be in the form of a comment next to the code itself.

Re:Git Things by 32bitkid on Monday January 01, 2024 @09:55AM (#38832174)
I’d take it one step further: if `git log`—a hierarchical view of the connection of commits—is the only way you (and your team) interact with commit messages, then yea it’s probably fine.

But, I think the value of commit messages become really apparent once you (or your team) are relying on other visualizations of commit messages like `blame` and `bisect`

Tracking down the introduction of a bug with bisect and resolving to a commit whose message in “minor”, because the person in the past didn’t think this change was important enough to describe intent can quite the temporal foot-gun.

Re:Git Things by forgotmypw17 on Monday January 01, 2024 @11:06AM (#38832786)
I would strongly disagree with it, because it misses the opportunity for using the commit message as a sanity check. Accidents happen, sometimes I select the wrong file for the commit, or include changes I didn't intend.

Even for the most minor commits, including "improve comment formatting ; utils.pl" allows skimming that message and comparing it to the actual commit.

It also helps me be aware of what I'm doing, pointing and calling style.

https://en.wikipedia.org/wiki/Pointing_and_calling

Re:Git Things by Cthulhu_ on Monday January 01, 2024 @03:00PM (#38834852)
To nitpick, the git commit already contains information about which files are affected; adding it explicitly to the commit message does not add value and, like comments, may be incorrect. I like the angular style guide's concept of "scope", like, what category or module of the application does it apply to.

That said, an "utils" file is often a smell in code organization.

Re:Git Things by joshka on Monday January 01, 2024 @06:12PM (#38836197)
> the git commit already contains information about which files are affected;

Contra: while this is true, it's worth considering how 'information about which files are effected' scales when examining the history of a repo. A commit message that simplifies and clarifies the intent is more useful than one that requires a future reader to read each git commit in full to understand the effect.

Re:Git Things by forgotmypw17 on Tuesday January 02, 2024 @11:27AM (#38843410)
> the git commit already contains information about which files are affected

Right, but this is not always the same as the files which I intended to be affected, and the matching of the two is the sanity check here.

utils was just an example filename.