From 448dd8c1d0fbbd91960069404eb2e1507102f949 Mon Sep 17 00:00:00 2001 From: Marcin Krystianc Date: Tue, 20 Sep 2022 12:48:31 +0200 Subject: [PATCH] DeltaStreamReader should interpret 0 size as 0x10000 https://git-scm.com/docs/pack-format/2.31.0#_instruction_to_copy_from_base_object: "In its most compact form, this instruction only takes up one byte (0x80) with both offset and size omitted, which will have default values zero. There is another exception: size zero is automatically converted to 0x10000." --- src/NerdBank.GitVersioning/ManagedGit/DeltaStreamReader.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NerdBank.GitVersioning/ManagedGit/DeltaStreamReader.cs b/src/NerdBank.GitVersioning/ManagedGit/DeltaStreamReader.cs index 08ee301e..a23020a9 100644 --- a/src/NerdBank.GitVersioning/ManagedGit/DeltaStreamReader.cs +++ b/src/NerdBank.GitVersioning/ManagedGit/DeltaStreamReader.cs @@ -84,6 +84,12 @@ public static class DeltaStreamReader { value.Size |= ((byte)stream.ReadByte() << 16); } + + // Size zero is automatically converted to 0x10000. + if (value.Size == 0) + { + value.Size = 0x10000; + } } return value;