Skip to content

Fix packfile tests on Go 1.27 - #45

Open
ssgelm wants to merge 1 commit into
git-lfs:mainfrom
ssgelm:fix-go-1.27-pack-tests
Open

ssgelm wants to merge 1 commit into
git-lfs:mainfrom
ssgelm:fix-go-1.27-pack-tests

Conversation

@ssgelm

@ssgelm ssgelm commented Sep 22, 2026

Copy link
Copy Markdown

Two tests in pack/packfile_test.go fail under Go 1.27. I hit this
building the Debian package, where
TestPackObjectReturnsObjectWithDeltaBaseOffset panics with a nil
pointer dereference.

Both tests hardcode offsets that assume zlib compresses "Hello" to 17
bytes and "Hello!\n" to 19. Go 1.27 emits 18 and 20, so the offsets
land on the wrong bytes. This computes them from len(compressed)
instead.

go test ./... passes with Go 1.25.0, 1.26.0 and 1.27.1. CI only
covers 1.25 and 1.26 right now, so it won't show the original failure.
Adding 1.27.x to the matrix could be a separate change.

Two of the packfile tests build a small pack in memory and then point
into it with byte offsets written as constants. Those constants only
hold if zlib turns "Hello" into 17 bytes and "Hello!\n" into 19, which
was true through Go 1.26.

Go 1.27 breaks that. It writes these short inputs as a stored block,
so each comes out one byte longer. The OFS_DELTA test then points one
byte past the base object's header and lands on the zlib header byte,
which decodes as an OBJ_REF_DELTA. The index lookup fails with "object
not found in index" and the test panics on the nil object. The
REF_DELTA test has the same problem with its index entry.

Both values are now computed from len(compressed), so the tests stop
depending on how many bytes the compressor emits. Tested with Go
1.25.0, 1.26.0 and 1.27.1.
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 this pull request may close these issues.

1 participant