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

Hi,

On Wed, 12 Oct 2005, Sergey Vlasov wrote:

> On Wed, 12 Oct 2005 13:02:36 +0200 (CEST) Johannes Schindelin wrote:
> 
> >  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).

Even worse, my code did not anticipate that the base objects could have 
been handled earlier (and thus the deltas would never be resolved).

> Saving unpacked objects in memory would obviously be unacceptable.

Actually, this is what git-unpack-objects does. All unresolved deltas are 
stored in a linked list, and handled later.

Of course, it would be nicer to use a seekable file if you have one. But 
then, I am not at all sure that base objects should be allowed to come 
later in the file: since the delta chains must not be cyclic, the objects
can be sorted. Thus, it could be guaranteed that the base objects are 
already unpacked when unpacking the derived object.

Ciao,
Dscho

  parent reply	other threads:[~2005-10-12 14:25 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
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   ` Johannes Schindelin [this message]
2005-10-12 14:55     ` [PATCH] Add '--create-index' to git-unpack-objects 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=Pine.LNX.4.63.0510121612340.6307@wbgn013.biozentrum.uni-wuerzburg.de \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=vsu@altlinux.ru \
    /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).