[PATCH 1/2] pack-format.txt: define "varint" format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We define our varint format pretty much on the fly as we describe a pack
file entry. In preparation for referring to it in more places in this
document, define "varint" and refer to it.

Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx>
---
 Documentation/technical/pack-format.txt | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
index f96b2e605f..42198de74c 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -55,6 +55,15 @@ Valid object types are:
 
 Type 5 is reserved for future expansion. Type 0 is invalid.
 
+=== Variable-length integer encoding
+
+This document uses "varint" encoding of non-negative integers: From
+each byte, the seven least significant bits are used to form the
+resulting integer. As long as the most significant bit is 1, this
+process continues; the byte with MSB 0 provides the last seven bits.
+The seven-bit chunks are concatenated. Later values are more
+significant.
+
 === Deltified representation
 
 Conceptually there are only four object types: commit, tree, tag and
@@ -196,10 +205,10 @@ Pack file entry: <+
 	1-byte size extension bit (MSB)
 	       type (next 3 bit)
 	       size0 (lower 4-bit)
-        n-byte sizeN (as long as MSB is set, each 7-bit)
-		size0..sizeN form 4+7+7+..+7 bit integer, size0
-		is the least significant part, and sizeN is the
-		most significant part.
+        n-byte size1 (varint encoding; present if MSB is set)
+        If the MSB is set, the size is size0 + 16*size1, otherwise
+        it is size0. (Equivalently, the entire packed object header
+        is a varint encoding of (size/16)*128 + type*16 + size%16.)
      packed object data:
         If it is not DELTA, then deflated bytes (the size above
 		is the size before compression).
-- 
2.30.0.rc1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux