gitbutlerapp/gitbutler · error

No oplog entry found matching SHA: {sha_prefix}

Error message

No oplog entry found matching SHA: {sha_prefix}

What it means

`but oplog --since <sha_prefix>` maps the prefix to a full oid with `repo.rev_parse_single(sha_prefix)`; any failure there (unknown object, ambiguous prefix, malformed input) is flattened into this message. Despite the wording, it means git could not resolve the revision in this repository at all — the oplog lookup is never reached. The resolved oid would otherwise be the lower bound for `snapshots_iter`.

Source

Thrown at crates/but/src/command/legacy/oplog.rs:43

        }
    }
}

pub(crate) fn show_oplog(
    ctx: &mut but_ctx::Context,
    out: &mut OutputChannel,
    since: Option<&str>,
    filter: Option<OplogFilter>,
) -> anyhow::Result<()> {
    // Convert filter to include_kind parameter for the API
    let include_kind = filter.map(|f| f.to_include_kinds());

    // Resolve partial SHA to full SHA using rev_parse if provided
    let since_sha = if let Some(sha_prefix) = since {
        let repo = ctx.repo.get()?;
        let resolved = repo
            .rev_parse_single(sha_prefix)
            .map_err(|_| anyhow::anyhow!("No oplog entry found matching SHA: {sha_prefix}"))?;
        Some(resolved.detach())
    } else {
        None
    };

    let snapshots = but_api::legacy::oplog::snapshots_iter(ctx, since_sha, None, include_kind)?
        .take(20)
        .collect::<anyhow::Result<Vec<_>>>()?;

    if snapshots.is_empty() {
        if let Some(out) = out.for_json() {
            out.write_value(&snapshots)?;
        } else if let Some(out) = out.for_human() {
            writeln!(out, "No operations found in history.")?;
        }
        return Ok(());
    }

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Validate the input yourself: `git rev-parse <sha_prefix>` — if git errors, but will too
  2. Use the full 40-char SHA from `but oplog` output or `git log`
  3. Lengthen an ambiguous prefix until `git rev-parse` returns a single oid
  4. Omit `--since` to list the latest snapshots regardless of bound

Example fix

# before
but oplog --since abc123
# error: No oplog entry found matching SHA: abc123

# after
git rev-parse abc123                      # verify it resolves; grab the full sha
but oplog --since "$(git rev-parse abc123)"
Defensive patterns

Strategy: validation

Validate before calling

# Resolve the --since bound before handing it to but
full_sha=$(git rev-parse --verify "${since}^{commit}") || { echo "bad revision: $since" >&2; exit 1; }
but oplog --since "$full_sha"

Prevention

When it happens

Trigger: Passing `--since` with a typo'd SHA, a prefix too short to be unique, an object id from a different repo/clone, or non-SHA input; `rev_parse_single` errors and the closure emits this anyhow error.

Common situations: SHA copied from another machine's logs; prefix truncated during copy-paste; shallow or partial clone missing the object; reflog-style input like HEAD@{2} where a raw sha is expected.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/d9d49c5986fd2cef. Report an issue: GitHub.