gitbutlerapp/gitbutler · error
snapshot checkout commit is null
Error message
snapshot checkout commit is null
What it means
Thrown by `snapshot_checkout` when the commit id read from the snapshot's checkout-commit blob is the all-zero object id. A null commit id cannot refer to any object, so GitButler refuses to build a `SnapshotCheckout` from it. Like the null-ref-target check, this guards against corrupt or malformed snapshot data.
Solutions
- Restore a different snapshot entry from the oplog that has a valid checkout commit id
- Inspect the snapshot tree blob (`git ls-tree <snapshot-tree>` / `git cat-file blob`) and verify the commit sha is a real 40-char hex id
- If the intended commit exists elsewhere, fix the blob to reference it, or recreate the branch at the desired commit and take a new snapshot
- Clear the oplog and start fresh if multiple snapshots are corrupt
Example fix
// corrupt checkout blob // before: commit_id = 0000000000000000000000000000000000000000 // after: commit_id = 3f9c2b8a1d0e4f5a6b7c8d9e0f1a2b3c4d5e6f70
Defensive patterns
Strategy: validation
Validate before calling
fn checkout_commit_blob_is_valid(repo: &gix::Repository, entry: &gix::tree::Entry) -> bool {
repo.find_blob(entry.id()).ok()
.and_then(|b| gix::ObjectId::from_hex(&b.data).ok())
.map(|id| !id.is_null())
.unwrap_or(false)
} Prevention
- Verify snapshot blobs contain real 40-char hex shas before restoring
- Avoid manual edits to `.git/gitbutler/` snapshot data
- Complete snapshot operations without interrupting the process
- Keep backups of the oplog if you script against it
When it happens
Trigger: `restore_snapshot` -> `snapshot_checkout` reads a checkout-commit blob containing 40 hex zeros instead of a valid commit sha.
Common situations: Interrupted or partially written snapshots; snapshots produced by buggy older GitButler versions; manual edits to oplog blobs; copying `.git` state between machines incompletely.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- snapshot additional ref target is null
- cannot restore a snapshot without checkout identity outside…
- Cannot restore branch
- cannot snapshot a null target commit id
- Change to discard at
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/f8e8616635f401fb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-oplog/src/oplog.rs:597
};
let commit_entry = snapshot_tree
.lookup_entry_by_path("checkout/commit")?
.context("snapshot checkout ref has no commit")?;
let ref_blob = repo
.find_blob(ref_entry.id())
.context("failed to read snapshot checkout ref")?;
let ref_name = gix::refs::FullName::try_from(ref_blob.data.as_bstr())
.context("snapshot checkout ref is invalid")?;
if ref_name.category() != Some(gix::refs::Category::LocalBranch) {
bail!("snapshot checkout ref is not a local branch");
}
let commit_blob = repo
.find_blob(commit_entry.id())
.context("failed to read snapshot checkout commit")?;
let commit_id = gix::ObjectId::from_hex(&commit_blob.data)
.context("snapshot checkout commit is invalid")?;
if commit_id.is_null() {
bail!("snapshot checkout commit is null");
}
Ok(Some(SnapshotCheckout {
ref_name,
commit_id,
}))
}
fn snapshot_metadata(
snapshot_tree: &gix::Tree<'_>,
repo: &gix::Repository,
) -> Result<(
ProjectMeta,
VirtualBranches,
Option<but_db::BranchOrderSnapshot>,
)> {
let vb_toml_entry = snapshot_tree
.lookup_entry_by_path("virtual_branches.toml")?
.context("failed to get virtual_branches.toml blob")?;View on GitHub (pinned to 58e5313667)