Official documentation about “Gerrit Change Number”

前端 未结 4 955
北荒
北荒 2021-01-22 02:20

This is a follow-up question of my other question: What is the official name of the number in a Gerrit review url

I have now learned that the small integer embedded in a

4条回答
  •  不知归路
    2021-01-22 02:51

    Change Number and Change-ID serve different purposes.

    From the Gerrit Docs on Change-Ids...

    Gerrit needs to identify commits that belong to the same review. For instance, when a change needs to be modified, a second commit can be uploaded to address the reported issues. Gerrit allows attaching those 2 commits to the same change, and relies upon a Change-Id line at the bottom of a commit message to do so. With this Change-Id, Gerrit can automatically associate a new version of a change back to its original review, even across cherry-picks and rebases.

    The Change-ID is a checksum used to identify the same change across rebases, amends, and other ways to rewrite commits in the course of review. Here's the key thing: Git does not rewrite commits. Git creates new commits and pretends it was that way all along. Gerrit needs a way to know that these new commits are, in fact, related to the ones you put up for review.

    More from the User Guide...

    If a commit that has a Change-Id in its commit message is pushed for review, Gerrit checks if a change with this Change-Id already exists for this project and target branch, and if yes, Gerrit creates a new patch set for this change. If not, a new change with the given Change-Id is created.

    If a commit without Change-Id is pushed for review, Gerrit creates a new change and generates a Change-Id for it.

    Amending and rebasing a commit preserves the Change-Id so that the new commit automatically becomes a new patch set of the existing change, when it is pushed for review.

    One way to look at it is the Change Number is the human readable identifier for a Change. The Change-ID is bookkeeping for Gerrit. The Change-ID is only visible to the user because Git has no way for Gerrit to store metadata about a commit other than putting it in the commit message.

提交回复
热议问题