Skip to content

Commit fef851a

Browse files
committed
integrated feedback from the git list to packfiles
1 parent 640afaf commit fef851a

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed
-1.65 KB
Loading
616 Bytes
Loading

script/html.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
require 'rdiscount'
66
require "uv"
77

8-
MIN_SIZE = 1200
8+
#MIN_SIZE = 1200
9+
MIN_SIZE = 800
910

1011
def do_replacements(html, type = :html)
1112

text/26_Advanced_Branching_And_Merging/0_Advanced_Branching_And_Merging.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ tip of the other branch, which is stored temporarily in MERGE_HEAD.
2626
During the merge, the index holds three versions of each file. Each of
2727
these three "file stages" represents a different version of the file:
2828

29-
$ git show :1:file.txt # the file in a common ancestor of both branches
30-
$ git show :2:file.txt # the version from HEAD.
31-
$ git show :3:file.txt # the version from MERGE_HEAD.
29+
$ git show :1:file.txt # the file in a common ancestor of both branches
30+
$ git show :2:file.txt # the version from HEAD.
31+
$ git show :3:file.txt # the version from MERGE_HEAD.
3232

3333
When you ask linkgit:git-diff[1] to show the conflicts, it runs a
3434
three-way diff between the conflicted merge results in the work tree with

text/26_Advanced_Branching_And_Merging/1_Advanced_Merging_Multiway_Merge_Subtree.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
### Multiway Merge ###
22

3-
4-
53
You can merge several heads at one time by simply listing them on the same
64
linkgit:git-merge[1] command. For instance,
75

text/52_The_Packfile/0_The_Packfile.markdown

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ bookmarks into a packfile.
1010

1111
There are two versions of the packfile index - version one, which is the default
1212
in versions of Git earlier than 1.6, and version two, which is the default
13-
from 1.6 forward, but which can be read by Git versions going back to 1.5.2.
13+
from 1.6 forward, but which can be read by Git versions going back to 1.5.2, and
14+
has been further backported to 1.4.4.5 if you are still on the 1.4 series.
1415

1516
Version 2 also includes a CRC checksum of each object so compressed data
1617
can be copied directly from pack to pack during repacking without
@@ -20,8 +21,15 @@ larger than 4 Gb.
2021
[fig:packfile-index]
2122

2223
In both formats, the fanout table is simply a way to find the offset of a
23-
particular sha faster within the index file. In version 1, the offsets and
24-
shas are in the same space, where in version two, there are seperate tables
24+
particular sha faster within the index file. The offset/sha1[]
25+
tables are sorted by sha1[] values (this is to allow binary search of this
26+
table), and fanout[] table points at the offset/sha1[] table in a specific
27+
way (so that part of the latter table that covers all hashes that start
28+
with a given byte can be found to avoid 8 iterations of the binary
29+
search).
30+
31+
In version 1, the offsets and shas are in the same space, where in version two,
32+
there are seperate tables
2533
for the shas, crc checksums and offsets. At the end of both files are
2634
checksum shas for both the index file and the packfile it references.
2735

@@ -33,12 +41,25 @@ a pack. The packfile format is used in upload-pack and receieve-pack programs
3341

3442
### The Packfile Format ###
3543

36-
The packfile itself is a very simple format. The first four bytes is the
37-
string 'PACK', which is sort of used to make sure you're getting the start
38-
of the packfile correctly. After that, you get a series of packed objects,
44+
The packfile itself is a very simple format. There is a header, a series of
45+
packed objects (each with it's own header and body) and then a checksum trailer.
46+
The first four bytes is the string 'PACK', which is sort of used to make sure
47+
you're getting the start of the packfile correctly. This is followed by a 4-byte
48+
packfile version number and then a 4-byte number of entries in that file. In
49+
Ruby, you might read the header data like this:
50+
51+
ruby
52+
def read_pack_header
53+
sig = @session.recv(4)
54+
ver = @session.recv(4).unpack("N")[0]
55+
entries = @session.recv(4).unpack("N")[0]
56+
[sig, ver, entries]
57+
end
58+
59+
After that, you get a series of packed objects, in order of thier SHAs
3960
which each consist of an object header and object contents. At the end
40-
of the packfile is a SHA1 sum of all the shas (in sorted order) in that
41-
packfile.
61+
of the packfile is a 20-byte SHA1 sum of all the shas (in sorted order) in that
62+
packfile.
4263

4364
[fig:packfile-format]
4465

@@ -64,4 +85,19 @@ It is important to note that the size specified in the header data is not
6485
the size of the data that actually follows, but the size of that data *when
6586
expanded*. This is why the offsets in the packfile index are so useful,
6687
otherwise you have to expand every object just to tell when the next header
67-
starts.
88+
starts.
89+
90+
The data part is just zlib stream for non-delta object types; for the two
91+
delta object representations, the data portion contains something that
92+
identifies which base object this delta representation depends on, and the
93+
delta to apply on the base object to resurrect this object. <code>ref-delta</code>
94+
uses 20-byte hash of the base object at the beginning of data, while
95+
<code>ofs-delta</code> stores an offset within the same packfile to identify the base
96+
object. In either case, two important constraints a reimplementor must
97+
adhere to are:
98+
99+
* delta representation must be based on some other object within the same
100+
packfile;
101+
102+
* the base object must be of the same underlying type (blob, tree, commit
103+
or tag);

0 commit comments

Comments
 (0)