GitoxideLabs/gitoxide · error · anyhow::Error

Only human output format is supported at the moment

Error message

Only human output format is supported at the moment

What it means

`gitoxide_core::repository::tree::entries` only implements human-readable rendering of tree contents. Any `OutputFormat` other than `Human` is rejected with `bail!` before resolving the treeish, so callers cannot request JSON output for tree listings. It is a deliberate feature-gate, not a runtime failure.

Solutions

  1. Use the default human format (omit `--format` or pass human).
  2. Call the underlying `gix` tree-traversal APIs yourself and emit your own JSON.
  3. Pipe through a converter that parses the human tree listing.
  4. Track upstream gitoxide for JSON tree output support.

Example fix

// before
entries(&repo, treeish, recursive, extended, OutputFormat::Json, out)?;
// after
let tree = treeish_to_tree(treeish, &repo)?;
for entry in tree.entries()? { /* serialize entry yourself */ }
Defensive patterns

Strategy: validation

Validate before calling

if format != OutputFormat::Human { format = OutputFormat::Human; // tree entries has no JSON yet }

Type guard

fn json_supported_tree_entries(f: &OutputFormat) -> bool { matches!(f, OutputFormat::Human) }

Try / catch

if let Err(e) = entries(&repo, treeish, rec, ext, format, &mut out) { if e.to_string().contains("Only human output format") { entries(&repo, treeish, rec, ext, OutputFormat::Human, &mut out)? } else { return Err(e.into()) } }

Prevention

When it happens

Trigger: Calling `entries(...)` with `format: OutputFormat::Json` (or another non-Human value), or running the CLI tree command with a JSON format flag (e.g. `gix tree entries --format json <treeish>`).

Common situations: Scripting `gix tree` output for pipelines; tooling that passes a uniform `--format json` flag to all subcommands; migrating from `git ls-tree` JSON wrappers expecting parity.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/4b40c72a6e35bed5. Report an issue: GitHub.

Appendix: source

Thrown at gitoxide-core/src/repository/tree.rs:159

    #[cfg(feature = "serde")]
    {
        delegate.stats.bytes = extended.then_some(delegate.stats.num_bytes);
        serde_json::to_writer_pretty(out, &delegate.stats)?;
    }

    Ok(())
}

pub fn entries(
    repo: gix::Repository,
    treeish: Option<&str>,
    recursive: bool,
    extended: bool,
    format: OutputFormat,
    mut out: impl io::Write,
) -> anyhow::Result<()> {
    if format != OutputFormat::Human {
        bail!("Only human output format is supported at the moment");
    }

    let tree = treeish_to_tree(treeish, &repo)?;

    if recursive {
        let mut write = BufWriter::new(out);
        let mut delegate = entries::Traverse::new(extended.then_some(&repo), Some(&mut write));
        tree.traverse().depthfirst(&mut delegate)?;
    } else {
        for entry in tree.iter() {
            let entry = entry?;
            format_entry(
                &mut out,
                &entry.inner,
                entry.inner.filename,
                extended.then(|| entry.id().header().map(|o| o.size())).transpose()?,
            )?;
        }

View on GitHub (pinned to e73179060b)