diff --git a/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar b/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar index 68372e1999f..d6c7fa19114 100644 Binary files a/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar and b/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar differ diff --git a/gix/tests/fixtures/make_rev_spec_parse_repos.sh b/gix/tests/fixtures/make_rev_spec_parse_repos.sh index 5ebbcbc3dea..baa2d924df9 100755 --- a/gix/tests/fixtures/make_rev_spec_parse_repos.sh +++ b/gix/tests/fixtures/make_rev_spec_parse_repos.sh @@ -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' +) \ No newline at end of file diff --git a/gix/tests/revision/spec/from_bytes/mod.rs b/gix/tests/revision/spec/from_bytes/mod.rs index 87e92a80d5e..713a8da8510 100644 --- a/gix/tests/revision/spec/from_bytes/mod.rs +++ b/gix/tests/revision/spec/from_bytes/mod.rs @@ -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();