| 1 |
From: Stephen Gelman <[email protected]> |
| 2 |
Subject: Compute pack test offsets from compressed length |
| 3 |
Two pack tests hardcoded offsets that only hold if zlib compresses the |
| 4 |
test strings to one exact length. Go 1.27 produces different output, so |
| 5 |
the offsets point at the wrong bytes and the tests fail. Derive them from |
| 6 |
len(compressed) instead. |
| 7 |
Forwarded: https://github.com/git-lfs/gitobj/pull/45 |
| 8 |
Last-Update: 2026-09-22 |
| 9 |
--- |
| 10 |
diff --git a/pack/packfile_test.go b/pack/packfile_test.go |
| 11 |
index 3f7db0e..1dc9e6a 100644 |
| 12 |
--- a/pack/packfile_test.go |
| 13 |
+++ b/pack/packfile_test.go |
| 14 |
@@ -108,8 +108,8 @@ func TestPackObjectReturnsObjectWithDeltaBaseOffset(t *testing.T) { |
| 15 |
|
| 16 |
0x35, // (0011 0101) (msb=0, type=blob, size=5) |
| 17 |
}, compressed...), append([]byte{ |
| 18 |
- 0x6e, // (0110 1010) (msb=0, type=obj_ofs_delta, size=10) |
| 19 |
- 0x12, // (0001 0001) (ofs_delta=-17, len(compressed)) |
| 20 |
+ 0x6e, // (0110 1010) (msb=0, type=obj_ofs_delta, size=10) |
| 21 |
+ byte(1 + len(compressed)), // ofs_delta: base header byte + len(compressed) |
| 22 |
}, delta...)...)), |
| 23 |
hash: sha1.New(), |
| 24 |
} |
| 25 |
@@ -147,7 +147,7 @@ func TestPackfileObjectReturnsObjectWithDeltaBaseReference(t *testing.T) { |
| 26 |
p := &Packfile{ |
| 27 |
idx: IndexWith(map[string]uint32{ |
| 28 |
"cccccccccccccccccccccccccccccccccccccccc": 32, |
| 29 |
- "dddddddddddddddddddddddddddddddddddddddd": 52, |
| 30 |
+ "dddddddddddddddddddddddddddddddddddddddd": uint32(32 + 1 + len(compressed)), |
| 31 |
}), |
| 32 |
r: bytes.NewReader(append(append([]byte{ |
| 33 |
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |