Repository
SHA-256 and reftable repositories
3 min read
Git is changing two internal formats, which will be the default in Git 3.0:
- SHA-256 (
--object-format=sha256): commits, trees and files are identified by a 64-character SHA-256 hash, instead of the 40-character SHA-1. - reftable (
--ref-format=reftable): branches, tags and the reflog are kept in a binary table (the.git/reftablefolder), instead of the loose files in.git/refs,packed-refsand the.git/logsfolder.
Repositories created with one or both formats work throughout Versora: graph, diff, blame, staging,
stash, rebase, cherry-pick, bisect, undo, worktrees, versora:// links and the rest. There's
nothing to turn on.
- 64-character SHAs. "Copy commit SHA" copies the full 64-character SHA. On screen, the short SHA still has 7 characters.
- Links and patches.
versora://links and patches (From <sha>) accept 64-character SHAs. - Branch names. When you push a new branch to a GitLab server, the push rules check warns, as GitLab itself would, when the branch name starts with 40 hexadecimal characters, because it can be mistaken for a SHA-1 or a SHA-256 ("GitLab doesn't accept SHA-1 or SHA-256 branch names (starting with 40 hexadecimal characters)"). See Checks.
- reftable. The app asks Git for what it used to read directly from files in the classic format (for example, the reflog and the state of a cherry-pick, revert or bisect stopped midway). You don't see any difference, except that the Optimize repository screen shows "reftable format" instead of the count of loose refs.
- Changes made outside the app. With reftable, all refs change inside
.git/reftable, and the app watches that folder to refresh the graph on its own.
Versora has no option of its own to choose the format when creating a repository. Use the terminal (the built-in terminal works) and then open the folder in Versora.
-
Create the repository in the new format:
git init --object-format=sha256 --ref-format=reftable meu-projetoThe two parameters are independent: use just one, if you want.
-
Open the folder in Versora (Ctrl+O or Home).
-
To check the format of an existing repository:
git rev-parse --show-object-format --show-ref-format
To convert the refs of an existing repository to reftable, Git has
git refs migrate --ref-format=reftable. After converting, reopen the repository in Versora: the
app reads the format once per folder and keeps the answer while the repository is open.
Caution
The object format (SHA-1 or SHA-256) isn't converted in place: a SHA-256 repository is a different repository, with different SHAs. Before adopting SHA-256, make sure your team's Git server supports that format.
- The reftable format requires a Git that knows it. The app asks for the format with
git rev-parse --show-ref-format, which exists since Git 2.45; with an older Git, the app treats the repository as having classic refs. - The app's other version requirements apply the same way: see Git version.
When it opens the repository, once per folder:
git rev-parse --show-object-format --show-ref-format
From then on, the app uses the empty tree and the null id of the right format (with 40 or 64 characters) and, with reftable, asks Git for the special refs (CHERRY_PICK_HEAD, REVERT_HEAD, REBASE_HEAD, ORIG_HEAD, BISECT_HEAD) instead of reading files.
There's nothing to undo: the app doesn't change the format of any repository.
There's no setting or policy key.