git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 09/21] pack-objects: recognize v4 as pack source
Date: Wed, 11 Sep 2013 13:06:10 +0700	[thread overview]
Message-ID: <1378879582-15372-10-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1378879582-15372-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c | 28 +++++++++++++++++++++++++---
 packv4-parse.h         |  2 ++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 63c9b9e..ac25973 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -19,6 +19,8 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packv4-create.h"
+#include "packv4-parse.h"
+#include "varint.h"
 
 static const char *pack_usage[] = {
 	N_("git pack-objects --stdout [options...] [< ref-list | < object-list]"),
@@ -1397,9 +1399,14 @@ static void check_object(struct object_entry *entry)
 		 * We want in_pack_type even if we do not reuse delta
 		 * since non-delta representations could still be reused.
 		 */
-		used = unpack_object_header_buffer(buf, avail,
-						   &entry->in_pack_type,
-						   &entry->size);
+		if (p->version < 4)
+			used = unpack_object_header_buffer(buf, avail,
+							   &entry->in_pack_type,
+							   &entry->size);
+		else
+			used = pv4_unpack_object_header_buffer(buf, avail,
+							       &entry->in_pack_type,
+							       &entry->size);
 		if (used == 0)
 			goto give_up;
 
@@ -1417,7 +1424,22 @@ static void check_object(struct object_entry *entry)
 				goto give_up;
 			unuse_pack(&w_curs);
 			return;
+		case OBJ_PV4_COMMIT:
+		case OBJ_PV4_TREE:
+			entry->type = entry->in_pack_type - 8;
+			entry->in_pack_header_size = used;
+			unuse_pack(&w_curs);
+			return;
 		case OBJ_REF_DELTA:
+			if (p->version == 4) {
+				const unsigned char *sha1, *cp;
+				cp = buf + used;
+				sha1 = get_sha1ref(p, &cp);
+				entry->in_pack_header_size = cp - buf;;
+				if (reuse_delta && !entry->preferred_base)
+					base_ref = sha1;
+				break;
+			}
 			if (reuse_delta && !entry->preferred_base)
 				base_ref = use_pack(p, &w_curs,
 						entry->in_pack_offset + used, NULL);
diff --git a/packv4-parse.h b/packv4-parse.h
index 52f52f5..d674a3f 100644
--- a/packv4-parse.h
+++ b/packv4-parse.h
@@ -14,6 +14,8 @@ unsigned long pv4_unpack_object_header_buffer(const unsigned char *base,
 					      unsigned long len,
 					      enum object_type *type,
 					      unsigned long *sizep);
+const unsigned char *get_sha1ref(struct packed_git *p,
+				 const unsigned char **bufp);
 
 void *pv4_get_commit(struct packed_git *p, struct pack_window **w_curs,
 		     off_t offset, unsigned long size);
-- 
1.8.2.82.gc24b958

  parent reply	other threads:[~2013-09-11  6:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09 19:52 [PULL REQUEST] initial pack v4 support Nicolas Pitre
2013-09-09 22:28 ` Junio C Hamano
2013-09-10 21:21 ` Junio C Hamano
2013-09-10 21:32   ` Nicolas Pitre
2013-09-10 21:52     ` Junio C Hamano
2013-09-10 22:31   ` Nicolas Pitre
2013-09-11  6:06   ` [PATCH 00/21] np/pack-v4 updates Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 01/21] fixup! pack-objects: prepare SHA-1 table in v4 Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 02/21] fixup! pack-objects: support writing pack v4 Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 03/21] fixup! pack v4: support "end-of-pack" indicator in index-pack and pack-objects Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 04/21] fixup! index-pack: parse v4 header and dictionaries Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 05/21] fixup! index-pack: record all delta bases in v4 (tree and ref-delta) Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 06/21] pack v4: lift dict size check in load_dict() Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 07/21] pack v4: move pv4 objhdr parsing code to packv4-parse.c Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 08/21] pack-objects: respect compression level in v4 Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` Nguyễn Thái Ngọc Duy [this message]
2013-09-11  6:06     ` [PATCH 10/21] pack v4: add a note that streaming does not support OBJ_PV4_* Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 11/21] unpack-objects: report missing object name Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 12/21] unpack-objects: recognize end-of-pack in v4 thin pack Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 13/21] unpack-objects: read v4 dictionaries Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 14/21] unpack-objects: decode v4 object header Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 15/21] unpack-objects: decode v4 ref-delta Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 16/21] unpack-objects: decode v4 commits Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 17/21] unpack-objects: allow to save processed bytes to a buffer Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 18/21] unpack-objects: decode v4 trees Nguyễn Thái Ngọc Duy
2013-09-11  6:06     ` [PATCH 19/21] index-pack, pack-objects: allow creating .idx v2 with .pack v4 Nguyễn Thái Ngọc Duy
2013-09-11 15:48       ` Nicolas Pitre
2013-09-11  6:06     ` [PATCH 20/21] show-index: acknowledge that it does not read .idx v3 Nguyễn Thái Ngọc Duy
2013-09-11 16:19       ` Nicolas Pitre
2013-09-11  6:06     ` [PATCH 21/21] t1050, t5500: replace the use of "show-index|wc -l" with verify-pack Nguyễn Thái Ngọc Duy
2013-09-11 14:21     ` [PATCH 00/21] np/pack-v4 updates Duy Nguyen
2013-09-11 16:25       ` Nicolas Pitre
2013-09-12  3:38         ` Duy Nguyen
2013-09-12 16:20           ` Nicolas Pitre
2013-09-13  1:11             ` Duy Nguyen
2013-09-11 16:24     ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378879582-15372-10-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@fluxnic.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).