# Package.Fetch: fix Git package fetching · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/80f3ef6e14a1213d1c3b31d515870afb43cc9379)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 80f3ef6e14a1213d1c3b31d515870afb43cc9379

Requested commit: 80f3ef6e14a1213d1c3b31d515870afb43cc9379

Commit: 80f3ef6e14a1213d1c3b31d515870afb43cc9379

Tree: baeb9d69b66b63cc8d08588e9ab94b12ebc68534

Author: Ian Johnson

Committer: Andrew Kelley

## Message

```
Package.Fetch: fix Git package fetching

This commit works around #18967 by adding an `AccumulatingReader`, which
accumulates data read from the underlying packfile, and by keeping track
of the position in the packfile and hash/checksum information separately
rather than using reader composition. That is, the packfile position and
hashes/checksums are updated with the accumulated read history data only
after we can determine what data has actually been used by the
decompressor rather than merely being buffered.

The only addition to the standard library APIs to support this change is
the `unreadBytes` function in `std.compress.flate.Inflate`, which allows
the user to determine how many bytes have been read only for buffering
and not used as part of compressed data.

These changes can be reverted if #18967 is resolved with a decompressor
that reads precisely only the number of bytes needed for decompression.

```

## Parents

- [5c25ad0fda23eca4b98aad48d709b3b1b9caf2d6](https://git.cafe/gitcafe/zig/commit/5c25ad0fda23eca4b98aad48d709b3b1b9caf2d6?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/80f3ef6e14a1213d1c3b31d515870afb43cc9379?format=markdown)
