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

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

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Oct 12, 2005, 13:34 UTC
Message-ID
<20051012173426.56fd5c1c.vsu@altlinux.ru>
In-Reply-To
<Pine.LNX.4.63.0510121301340.30679@wbgn013.biozentrum.uni-wuerzburg.de>
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.
Show 15 quoted lines
> @@ -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.

Previous: Johannes SchindelinNext: Sergey Vlasov
Message 2 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.