Skip to content

Commit c151b8d

Browse files
committed
add minimal test for sorting issues of loose refs (#1928)
1 parent 24f40b9 commit c151b8d

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q
5+
6+
mkdir -p .git/refs/heads/a
7+
cat <<EOF >.git/packed-refs
8+
# pack-refs with: peeled fully-peeled sorted
9+
1111111111111111111111111111111111111111 refs/heads/a-
10+
2222222222222222222222222222222222222222 refs/heads/a/b
11+
3333333333333333333333333333333333333333 refs/heads/a0
12+
EOF
13+
14+
mkdir -p .git/refs/heads/a
15+
echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >.git/refs/heads/a-
16+
echo bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb >.git/refs/heads/a/b
17+
echo cccccccccccccccccccccccccccccccccccccccc >.git/refs/heads/a0

gix-ref/tests/refs/file/store/iter.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,45 @@ fn overlay_iter_reproduce_1850() -> crate::Result {
464464
Ok(())
465465
}
466466

467+
#[test]
468+
fn overlay_iter_reproduce_1928() -> crate::Result {
469+
let store = store_at("make_repo_for_1928_repro.sh")?;
470+
let ref_names = store
471+
.iter()?
472+
.all()?
473+
.map(|r| r.map(|r| (r.name.as_bstr().to_owned(), r.target)))
474+
.collect::<Result<Vec<_>, _>>()?;
475+
insta::assert_debug_snapshot!(ref_names, @r#"
476+
[
477+
(
478+
"refs/heads/a-",
479+
Object(
480+
Sha1(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),
481+
),
482+
),
483+
(
484+
"refs/heads/a/b",
485+
Object(
486+
Sha1(2222222222222222222222222222222222222222),
487+
),
488+
),
489+
(
490+
"refs/heads/a0",
491+
Object(
492+
Sha1(cccccccccccccccccccccccccccccccccccccccc),
493+
),
494+
),
495+
(
496+
"refs/heads/a/b",
497+
Object(
498+
Sha1(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb),
499+
),
500+
),
501+
]
502+
"#);
503+
Ok(())
504+
}
505+
467506
#[test]
468507
fn overlay_iter_with_prefix_wont_allow_absolute_paths() -> crate::Result {
469508
let store = store_with_packed_refs()?;

0 commit comments

Comments
 (0)