Skip to content

Instantly share code, notes, and snippets.

@jennings
Last active March 27, 2025 05:00
Show Gist options
  • Save jennings/eb3bdea3e5d33893aaed9874be9f87d4 to your computer and use it in GitHub Desktop.
Save jennings/eb3bdea3e5d33893aaed9874be9f87d4 to your computer and use it in GitHub Desktop.

General idea

Jujutsu should treat the change-id header as an opaque string. However, if the value happens to be formatted like a Jujutsu change ID (40 character reverse hex), then try to use it as the Jujutsu change ID as well.

If the community agrees to use jj's format, then everyone sees jj-style change IDs, and Jujutsu behaves as though they really are change IDs. If a competing format appears, jj can still use it to track amended commits but doesn't get confused and try to use it as the actual change ID.

Workflow

When creating a new commit

  • Assign the change ID as the change-id header in the reverse-hex format:

    change-id yzsvttkkvmwzqnxrlyttlkynnppwrnmo
    

When rewriting a commit

  • If the commit has a change-id header, preserve it
  • Otherwise, add the header to the rewritten commit with the value of the jj change ID

When importing a commit from Git

  • If the change-id header exists:

    • If it parses as a jj change ID:

      • If the change ID doesn't yet exist, assign it to the incoming commit.
      • If the change ID exists and is assigned to a visible, mutable commit, assign it to the incoming commit and hide the predecessor.
      • If the change ID exists and is assigned to a visible, immutable commit, (?)
    • If the change-id header exists but cannot be parsed as a jj change ID:

      • Look up the incoming change-id in a lookup table mapping change-id headers to jj change IDs
        • If found, the incoming commit is assigned the found change ID
        • If not found, the incoming commit is assigned a new change ID and the mapping is added to the lookup table.
  • If the change-id header does not exist, import the commit as-is and generate a new change ID.

Reasoning

If Jujutsu's change ID format is adopted by the whole community, then everyone wins: jj change IDs get transmitted across the wire, they show up in forge UIs, etc.

If multiple change ID formats exist, then jj still supports them to the best of its ability:

  • If it's a jj-written change-id, then the reverse hex change ID will get transmitted along with the commit.

  • If it's in any other format (say, a UUID), then jj can still use it to identify commits, it just doesn't become the normal change ID (the value should probably be displayed somewhere, maybe in jj show)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment