News for hackers. Stuff that matters.
Re:The Perfect Commit by Quekid5 on Sunday October 30, 2022 @05:33AM (#33392756)
> I actually wish more pepole would use the email patch review process. At least there, reviewing individual commits is the default and the relation among multiple commits is preserved. I'm not sure how that's accomplished in Gerrit.

Gerrit adds a changeset-id (changeset = patch) to each commit message via local hooks -- this allows for tracking patches even when rewriting. (Ofc, if you remove/rewrite the changeset-id the connection gets broken, but it's pretty rare that that happens.)

Other than that it basically functions exactly like a more user-friendly patches-as-email.

Re:The Perfect Commit by u801e on Monday October 31, 2022 @02:58AM (#33402759)
So, if you implement a feature that involves multiple commits, when you push the branch up, will all the commits in the branch have the same changeset-id? If not, how is the relation between commits on a branch maintained during review and in the history after the branch is merged?
Re:The Perfect Commit by Quekid5 on Monday October 31, 2022 @08:17AM (#33404709)
No, each commit has its own changeset ID. The chain itself is tracked by Gerrit itself. I don't know exactly how, put I'm guesssing it's just using the regular git commit IDs for that. (The changeset ID is just so that it can identify patches long-term, even when their commit ID changes due to e.g. rebase, etc.)

> the history after the branch is merged

Regular commit IDs do that -- although it stores repos and full history, Gerrit doesn't really care about changeset-id's once they're merged.

Re:The Perfect Commit by u801e on Monday October 31, 2022 @02:43PM (#33410623)
>> the [branch] history after the branch is merged

> Regular commit IDs do that -- although it stores repos and full history, Gerrit doesn't really care about changeset-id's once they're merged.

In git itself, related commits in a branch can be identified using the merge commit, because that commit's parent commits correspond to the head commit and base commit of that branch. So to look at the commits in a branch after it had been merged, you can do something like:

  git log merge-commit^1..merge-commit^2
This allows you to see the per commit changes as well as the overall change introduced by the branch. You mentioned that gerrit tracks that chain. Since it's not via change-set ids, then does it keep track of related commits in a branch?
Re:The Perfect Commit by Quekid5 on Wednesday November 02, 2022 @06:59AM (#33433870)
> Since it's not via change-set ids, then does it keep track of related commits in a branch?

It is via changeset-Ids correlating to individual commits. The changeset-Ids only serve as a permanent identifier to individual commits.

Everything else comes via the regular backward chain of commit IDs. (Until it hits an already-known/merged commit or an unrelated commit which it knows a changeset-ID for. Not sure of the exact details, but it works as one would expect.)

(Even though Gerrit does support branches and submitting commit to specific branches, etc. we use it in a branchless way in almost all of our projects. Nor do we do merge commits.)