git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add '--create-index' to git-unpack-objects

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 12, 2005, 14:25 UTC
Message-ID
<Pine.LNX.4.63.0510121612340.6307@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<20051012173426.56fd5c1c.vsu@altlinux.ru>
Hi,
On Wed, 12 Oct 2005, Sergey Vlasov wrote:
Show 21 quoted lines
> 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

Previous: Junio C HamanoNext: Sergey Vlasov
Message 9 of 12 in “Add '--create-index' to git-unpack-objects”
  1. Add '--create-index' to git-unpack-objectsJohannes Schindelin, Oct 12, 2005
  2. Sergey VlasovOct 12, 2005
  3. Add git-index-pack utilitySergey Vlasov, Oct 12, 2005
  4. Johannes SchindelinOct 12, 2005
  5. Sergey VlasovOct 12, 2005
  6. Fix packname hash generation.Junio C Hamano, Oct 12, 2005
  7. clone-pack: new option --keep to keep the pack unexploded.Junio C Hamano, Oct 13, 2005
  8. Junio C HamanoOct 13, 2005
  9. Johannes SchindelinOct 12, 2005
  10. Sergey VlasovOct 12, 2005
  11. Johannes SchindelinOct 12, 2005
  12. Linus TorvaldsOct 12, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.