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

Re: [PATCH 08/12] pack-write: switch various SHA-1 values to abstract forms

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 28, 2018, 21:52 UTC
Message-ID
<20180128215207.GL431130@genre.crustytoothpaste.net>
In-Reply-To
<76f6c291-9c48-279d-3bb6-fc42a8e0eb9b@gmail.com>
On Sun, Jan 28, 2018 at 09:30:36PM +0100, Patryk Obara wrote:
Show 10 quoted lines
> On 28/01/2018 16:57, brian m. carlson wrote:
> >   		if (partial_pack_offset == 0) {
> > -			unsigned char sha1[20];
> > -			git_SHA1_Final(sha1, &old_sha1_ctx);
> > -			if (hashcmp(sha1, partial_pack_sha1) != 0)
> > +			unsigned char hash[GIT_MAX_RAWSZ];
> > +			the_hash_algo->final_fn(hash, &old_hash_ctx);
> > +			if (hashcmp(hash, partial_pack_hash) != 0)
> 
> Maybe "hash" should be struct object_id here?

In this case, I opted not to do that because it's specifically not an object ID. It's a checksum for the pack, which isn't a normal Git object, so I tried to preserve that distinction.

Show 7 quoted lines
> >   char *index_pack_lockfile(int ip_out)
> >   {
> > -	char packname[46];
> > +	char packname[GIT_MAX_HEXSZ + 6];
> > +	int len = the_hash_algo->hexsz + 6;
> 
> Just me nitpicking, but "len" can be const :)

I wanted it to be const, too, but I recall getting feedback discouraging it. I"m happy to make the change; after all, it can only help the compiler and any future readers.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Previous: Patryk ObaraNext: Patryk Obara
Message 20 of 22 in “object_id part 11 (the_hash_algo)”
  1. 00/12 object_id part 11 (the_hash_algo)brian m. carlson, Jan 28, 2018
  2. 01/12 hash: move SHA-1 macros to hash.hbrian m. carlson, Jan 28, 2018
  3. 04/12 builtin/unpack-objects: switch uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  4. 05/12 sha1_file: switch uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  5. 06/12 fast-import: switch various uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  6. Patryk ObaraJan 28, 2018
  7. 09/12 read-cache: abstract away uses of SHA-1brian m. carlson, Jan 28, 2018
  8. Eric SunshineJan 28, 2018
  9. brian m. carlsonJan 28, 2018
  10. 12/12 bulk-checkin: abstract SHA-1 usagebrian m. carlson, Jan 28, 2018
  11. 03/12 builtin/index-pack: improve hash function abstractionbrian m. carlson, Jan 28, 2018
  12. 11/12 csum-file: abstract uses of SHA-1brian m. carlson, Jan 28, 2018
  13. 10/12 csum-file: rename sha1file to hashfilebrian m. carlson, Jan 28, 2018
  14. 02/12 hash: create union for hash context allocationbrian m. carlson, Jan 28, 2018
  15. Patryk ObaraJan 28, 2018
  16. brian m. carlsonJan 28, 2018
  17. 07/12 pack-check: convert various uses of SHA-1 to abstract formsbrian m. carlson, Jan 28, 2018
  18. 08/12 pack-write: switch various SHA-1 values to abstract formsbrian m. carlson, Jan 28, 2018
  19. Patryk ObaraJan 28, 2018
  20. brian m. carlsonJan 28, 2018
  21. Patryk ObaraJan 28, 2018
  22. brian m. carlsonJan 28, 2018

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.