Skip to content

Commit

Permalink
reproduce panic when parsing refspecs (#1508)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 11, 2024
1 parent 1926d08 commit 17bd32a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Binary file not shown.
8 changes: 8 additions & 0 deletions gix/tests/fixtures/make_rev_spec_parse_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,11 @@ git init new
(cd new
baseline '@{1}'
)
git init invalid-head
(cd invalid-head
>file && git add file && git commit -m "init"
rm .git/refs/heads/main
baseline 'HEAD'
baseline 'HEAD:file'
)
10 changes: 10 additions & 0 deletions gix/tests/revision/spec/from_bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ fn access_blob_through_tree() {
);
}

#[test]
fn invalid_head() {
let repo = repo("invalid-head").unwrap();
let err = parse_spec("HEAD", &repo).unwrap_err();
assert_eq!(err.to_string(), "The rev-spec is malformed and misses a ref name");

let err = parse_spec("HEAD:file", &repo).unwrap_err();
assert_eq!(err.to_string(), "TBD");
}

#[test]
fn empty_tree_as_full_name() {
let repo = repo("complex_graph").unwrap();
Expand Down

0 comments on commit 17bd32a

Please sign in to comment.