From 9170c7ab2889a295de49458d7bd37d82f1556cd6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 27 Apr 2012 15:58:13 -0700 Subject: [PATCH 1/2] unpack-trees: preserve the index file version of original Otherwise "git checkout $other_branch" (or even "git checkout HEAD") would end up writing the index out in the default format. Signed-off-by: Junio C Hamano --- unpack-trees.c | 1 + 1 file changed, 1 insertion(+) diff --git a/unpack-trees.c b/unpack-trees.c index 7c9ecf665d..2a037d6a42 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1020,6 +1020,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options o->result.initialized = 1; o->result.timestamp.sec = o->src_index->timestamp.sec; o->result.timestamp.nsec = o->src_index->timestamp.nsec; + o->result.version = o->src_index->version; o->merge_size = len; mark_all_ce_unused(o->src_index); From afd7bd22209c53ae4d3c73dd4bc4b225ec55e10a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 27 Apr 2012 16:02:45 -0700 Subject: [PATCH 2/2] index-v4: document the entry format Document the format so that others can learn from and build on top of the series. Signed-off-by: Junio C Hamano --- Documentation/technical/index-format.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/technical/index-format.txt b/Documentation/technical/index-format.txt index 8930b3fabc..9d25b30178 100644 --- a/Documentation/technical/index-format.txt +++ b/Documentation/technical/index-format.txt @@ -113,9 +113,22 @@ GIT index format are encoded in 7-bit ASCII and the encoding cannot contain a NUL byte (iow, this is a UNIX pathname). + (Version 4) In version 4, the entry path name is prefix-compressed + relative to the path name for the previous entry (the very first + entry is encoded as if the path name for the previous entry is an + empty string). At the beginning of an entry, an integer N in the + variable width encoding (the same encoding as the offset is encoded + for OFS_DELTA pack entries; see pack-format.txt) is stored, followed + by a NUL-terminated string S. Removing N bytes from the end of the + path name for the previous entry, and replacing it with the string S + yields the path name for this entry. + 1-8 nul bytes as necessary to pad the entry to a multiple of eight bytes while keeping the name NUL-terminated. + (Version 4) In version 4, the padding after the pathname does not + exist. + == Extensions === Cached tree