From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.176.0/21 X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MSGID_FROM_MTA_HEADER,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 From: Nicolas Pitre Subject: Re: [PATCH 1/2] Allow pack header preprocessing before unpack-objects/index-pack. Date: Tue, 31 Oct 2006 14:33:09 -0500 (EST) Message-ID: References: <20061031075629.GA7691@spearce.org> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: 7BIT NNTP-Posting-Date: Tue, 31 Oct 2006 19:34:02 +0000 (UTC) Cc: Junio C Hamano , git@vger.kernel.org Return-path: Envelope-to: gcvg-git@gmane.org In-reply-to: <20061031075629.GA7691@spearce.org> X-X-Sender: nico@xanadu.home Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: Received: from vger.kernel.org ([209.132.176.167]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GezMa-00071d-0s for gcvg-git@gmane.org; Tue, 31 Oct 2006 20:33:32 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423820AbWJaTdM (ORCPT ); Tue, 31 Oct 2006 14:33:12 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1423822AbWJaTdL (ORCPT ); Tue, 31 Oct 2006 14:33:11 -0500 Received: from relais.videotron.ca ([24.201.245.36]:8290 "EHLO relais.videotron.ca") by vger.kernel.org with ESMTP id S1423820AbWJaTdK (ORCPT ); Tue, 31 Oct 2006 14:33:10 -0500 Received: from xanadu.home ([74.56.106.175]) by VL-MH-MR001.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0J80008F4MB9BFG0@VL-MH-MR001.ip.videotron.ca> for git@vger.kernel.org; Tue, 31 Oct 2006 14:33:09 -0500 (EST) To: Shawn Pearce Sender: git-owner@vger.kernel.org On Tue, 31 Oct 2006, Shawn Pearce wrote: > However if the caller consumes the pack header from the input stream > then its no longer available for unpack-objects or index-pack --stdin, > both of which need the version and object count to process the stream. > > This change introduces --pack_header=ver,cnt as a command line option > that the caller can supply to indicate it has already consumed the > pack header and what version and object count were found in that > header. As this option is only meant for low level applications > such as receive-pack we are not documenting it at this time. This breaks index-pack, and unpack-objects with OBJ_OFS_DELTA, if --pack-header is used. The header is not accounted in the pack's offset and therefore every object's offset is wrong. What about this patch instead? This makes things much simpler IMHO. diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index 74a90c1..e6d7574 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -371,6 +371,21 @@ int cmd_unpack_objects(int argc, const c recover = 1; continue; } + if (!strncmp(arg, "--pack_header=", 14)) { + struct pack_header *hdr; + char *c; + + hdr = (struct pack_header *)buffer; + hdr->hdr_signature = htonl(PACK_SIGNATURE); + hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10)); + if (*c != ',') + die("bad %s", arg); + hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10)); + if (*c) + die("bad %s", arg); + len = sizeof(*hdr); + continue; + } usage(unpack_usage); } diff --git a/index-pack.c b/index-pack.c index b37dd78..a3b55f9 100644 --- a/index-pack.c +++ b/index-pack.c @@ -841,6 +841,19 @@ int main(int argc, char **argv) keep_msg = ""; } else if (!strncmp(arg, "--keep=", 7)) { keep_msg = arg + 7; + } else if (!strncmp(arg, "--pack_header=", 14)) { + struct pack_header *hdr; + char *c; + + hdr = (struct pack_header *)input_buffer; + hdr->hdr_signature = htonl(PACK_SIGNATURE); + hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10)); + if (*c != ',') + die("bad %s", arg); + hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10)); + if (*c) + die("bad %s", arg); + input_len = sizeof(*hdr); } else if (!strcmp(arg, "-v")) { verbose = 1; } else if (!strcmp(arg, "-o")) {