git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@altlinux.ru>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, junkio@cox.net
Subject: Re: [PATCH] Add '--create-index' to git-unpack-objects
Date: Wed, 12 Oct 2005 17:34:26 +0400	[thread overview]
Message-ID: <20051012173426.56fd5c1c.vsu@altlinux.ru> (raw)
In-Reply-To: <Pine.LNX.4.63.0510121301340.30679@wbgn013.biozentrum.uni-wuerzburg.de>

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

On Wed, 12 Oct 2005 13:02:36 +0200 (CEST) Johannes Schindelin wrote:

> Add the option '--create-index' to git-unpack-objects, which makes it 
> create an index file instead of expanding its contents. While at it, 
> document the dry-run option '-n', and optionally take a pack file instead 
> of stdin.


> @@ -104,7 +119,15 @@ static void added_object(unsigned char *
>  static void write_object(void *buf, unsigned long size, const char *type)
>  {
>  	unsigned char sha1[20];
> -	if (write_sha1_file(buf, size, type, sha1) < 0)
> +	if (create_index) {
> +		char header[100];
> +		SHA_CTX c;
> +
> +		SHA1_Init(&c);
> +		SHA1_Update(&c, header, 1+sprintf(header, "%s %lu", type, size));
> +		SHA1_Update(&c, buf, size);
> +		SHA1_Final(current_sha1, &c);
> +	} else if (write_sha1_file(buf, size, type, sha1) < 0)
>  		die("failed to write object");

Sorry, but this cannot work.  git-unpack-objects does a streaming
unpack, and it needs to be able to read back the objects it has written
out previously (in case a delta later in the stream references some
older object).  Saving unpacked objects in memory would obviously be
unacceptable.

However, if you need to create a pack index, you obviously have a pack
file with random access ability, and in this case it is possible to
build the index efficiently (in two passes over the pack file) without
storing unpacked objects in the filesystem.  I made a separate utility
to do this; will send a patch in some minutes.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-10-12 13:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12 11:02 [PATCH] Add '--create-index' to git-unpack-objects Johannes Schindelin
2005-10-12 13:34 ` Sergey Vlasov [this message]
2005-10-12 13:54   ` [PATCH] Add git-index-pack utility Sergey Vlasov
2005-10-12 14:33     ` Johannes Schindelin
2005-10-12 15:01       ` Sergey Vlasov
2005-10-12 23:57     ` [PATCH] Fix packname hash generation Junio C Hamano
2005-10-13  1:23       ` [PATCH] clone-pack: new option --keep to keep the pack unexploded Junio C Hamano
2005-10-13  2:46       ` [PATCH] Fix packname hash generation Junio C Hamano
2005-10-12 14:25   ` [PATCH] Add '--create-index' to git-unpack-objects Johannes Schindelin
2005-10-12 14:55     ` Sergey Vlasov
2005-10-12 15:08       ` Johannes Schindelin
2005-10-12 15:20       ` Linus Torvalds

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=20051012173426.56fd5c1c.vsu@altlinux.ru \
    --to=vsu@altlinux.ru \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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).