2
0
Эх сурвалжийг харах

pack.write_pack_data: when writing OFS_DELTA entries, write correct offset

The old code wrote the OFS_DELTA offset as the offset from the start
of the pack file, which is
wrong. git.git/Documentation/technical/pack-format.txt states that the
offset is the number of bytes before the current object header that
the base object header starts, which is what we now write.

A future patch will exercise this code by enabling the writing of
deltas during packing.

Change-Id: Ie8431339e4ca3a6cc4e1969b90150b7a6e464d4c
Augie Fackler 11 жил өмнө
parent
commit
8dba3aa25a
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      dulwich/pack.py

+ 2 - 2
dulwich/pack.py

@@ -1544,6 +1544,7 @@ def write_pack_data(f, num_records, records):
     f = SHA1Writer(f)
     write_pack_header(f, num_records)
     for type_num, object_id, delta_base, raw in records:
+        offset = f.offset()
         if delta_base is not None:
             try:
                 base_offset, base_crc32 = entries[delta_base]
@@ -1552,8 +1553,7 @@ def write_pack_data(f, num_records, records):
                 raw = (delta_base, raw)
             else:
                 type_num = OFS_DELTA
-                raw = (base_offset, raw)
-        offset = f.offset()
+                raw = (offset - base_offset, raw)
         crc32 = write_pack_object(f, type_num, raw)
         entries[object_id] = (offset, crc32)
     return entries, f.write_sha()