Skip to content
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

Panic when parsing HEAD:README in a repo with invalid HEAD. #1508

Closed
axelkar opened this issue Aug 11, 2024 · 2 comments · Fixed by #1509
Closed

Panic when parsing HEAD:README in a repo with invalid HEAD. #1508

axelkar opened this issue Aug 11, 2024 · 2 comments · Fixed by #1509
Assignees

Comments

@axelkar
Copy link

axelkar commented Aug 11, 2024

Current behavior 😯

thread 'tokio-runtime-worker' panicked at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/revision/spec/parse/error.rs:108:9:
assertion failed: !errors.is_empty()
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: gix::revision::spec::parse::error::<impl gix::revision::spec::parse::types::Error>::from_errors
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/revision/spec/parse/error.rs:108:9
   4: gix::revision::spec::parse::delegate::<impl gix::revision::spec::parse::Delegate>::into_err
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/revision/spec/parse/delegate/mod.rs:44:9
   5: gix::revision::spec::parse::<impl gix::revision::Spec>::_from_bstr_inner_generated_by_gix_macro_momo
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/revision/spec/parse/mod.rs:41:48
   6: gix::revision::spec::parse::<impl gix::revision::Spec>::from_bstr
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/revision/spec/parse/mod.rs:37:5
   7: gix::repository::revision::<impl gix::types::Repository>::_rev_parse_inner_generated_by_gix_macro_momo
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/repository/revision.rs:16:9
   8: gix::repository::revision::<impl gix::types::Repository>::rev_parse
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/repository/revision.rs:14:5
   9: gix::repository::revision::<impl gix::types::Repository>::rev_parse_single
             at /home/axel/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/gix-0.64.0/src/repository/revision.rs:33:9
  10: rgitweb::repo_home::{{closure}}
             at ./src/main.rs:354:13
*super verbose tokio, axum and tower stack trace*
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected behavior 🤔

It shouldn't panic.

Git behavior

Talks about nonexistent branch being empty. Not sure about libgit2.

Steps to reproduce 🕹

let repo = gix::open("nixos_iced_aw.git").unwrap();
let _ = repo.rev_parse_single("HEAD:README");
// Doesn't get here

nixos_iced_aw.got is a bare repository whose HEAD points to the master branch, which has been deleted.
Here's the repo: https://git.axka.fi/nixos_iced_aw.git. I'm not sure if cloning it will reproduce this, but you can make a bare repo with a commit and then point HEAD to something non-existent.

Cgit deals with it, Git says fatal: your current branch 'master' does not have any commits yet and gix panics.

@Byron Byron self-assigned this Aug 11, 2024
@Byron
Copy link
Member

Byron commented Aug 11, 2024

Thank you for reporting! I could reproduce the issue and am working on a fix.

Byron added a commit that referenced this issue Aug 11, 2024
@Byron Byron mentioned this issue Aug 11, 2024
2 tasks
@Byron
Copy link
Member

Byron commented Aug 11, 2024

When released, gix will instead say: Could not peel 'HEAD' to obtain its target.

LuaKT pushed a commit to LMonitor/gitoxide that referenced this issue Aug 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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