Skip to content

Indexer::new() fails with message "no error" #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jacks0n9 opened this issue May 5, 2025 · 1 comment · Fixed by #1160
Closed

Indexer::new() fails with message "no error" #1159

jacks0n9 opened this issue May 5, 2025 · 1 comment · Fixed by #1160

Comments

@jacks0n9
Copy link

jacks0n9 commented May 5, 2025

Reproduction code:

use std::path::Path;

use git2::Indexer;

fn main() {
    Indexer::new(
        None,
        Path::new("pack-deb8057d446a5ab60cd17f2ff20862add62b883b.pack"),
        0,
        false,
    )
    .unwrap();
}

This code will fail, even though the pack is valid and generated by git itself. The pack used in this example has the data (here shown in base64) of:
UEFDSwAAAAIAAAABNXicS0xMTOQCAAVdAY/euAV9RGpatgzRfy/yCGKt1iuIOw==
The output of running this program is the following:

thread 'main' panicked at src/main.rs:12:6:
called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 0, message: "no error" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This pack contains only one four-character blob object with the text "aaaa". This issue makes it impossible to create an indexer without an ODB for certain, but I have not tested this with an ODB.

@ehuss
Copy link
Contributor

ehuss commented May 5, 2025

I think there might be a misunderstanding of how to use the Indexer api. The path should be a directory where the index and pack files will be stored. Then, if you have some data to write, you just use the write method of the Indexer (and then commit).

The "no error" is due to a missing call to crate::init() in the Indexer::new method. I have opened #1160 to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants