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

Re: [PATCH v5 01/12] sha1-file: rename algorithm to "sha1"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 5, 2018, 07:21 UTC
Message-ID
<87a7mo7zwn.fsf@evledraar.gmail.com>
In-Reply-To
<20181104234458.139223-2-sandals@crustytoothpaste.net>
On Sun, Nov 04 2018, brian m. carlson wrote:
Show 6 quoted lines
> The transition plan anticipates us using a syntax such as "^{sha1}" for
> disambiguation.  Since this is a syntax some people will be typing a
> lot, it makes sense to provide a short, easy-to-type syntax.  Omitting
> the dash doesn't create any ambiguity; however, it does make the syntax
> shorter and easier to type, especially for touch typists.  In addition,
> the transition plan already uses "sha1" in this context.
The comment for git_hash_algo's "name" member in hash.h says:
	/*
	 * The name of the algorithm, as appears in the config file and in
	 * messages.
	 */
	const char *name;

Whereas this commit message just refers to a doesn't-yet-exist ^{$algo} syntax. The hash-function-transition.txt doc also uses forms like sha1 or sha256 in config, not sha-1 or sha-256.

I don't have a point I'm leading up to here, other than a question of whether we should be doing something closer to this:

diff --git a/hash.h b/hash.h
index 7c8238bc2e..8ae51ac410 100644
--- a/hash.h
+++ b/hash.h
@@ -67,10 +67,17 @@ typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);

 struct git_hash_algo {
 	/*
-	 * The name of the algorithm, as appears in the config file and in
-	 * messages.
+	 * The short name of the algorithm (e.g. "sha1") for use in
+	 * config files (see hash-function-transition.txt) and the
+	 * ^{$name} peel syntax.
 	 */
-	const char *name;
+	const char *short_name;
+
+	/*
+	 * The long name of the algorithm (e.g. "SHA-1") for use in
+	 * messages to users.
+	 */
+	const char *long_name;

 	/* A four-byte version identifier, used in pack indices. */
 	uint32_t format_id;
diff --git a/sha1-file.c b/sha1-file.c
index dd0b6aa873..5ad0526155 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -86,6 +86,7 @@ static void git_hash_unknown_final(unsigned char *hash, git_hash_ctx *ctx)

 const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
 	{
+		NULL,
 		NULL,
 		0x00000000,
 		0,
@@ -97,7 +98,8 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
 		NULL,
 	},
 	{
-		"sha-1",
+		"sha1",
+		"SHA-1",
 		/* "sha1", big-endian */
 		0x73686131,
 		GIT_SHA1_RAWSZ,
Previous: brian m. carlsonNext: brian m. carlson
Message 22 of 58 in “Base SHA-256 implementation”
  1. 00/12 Base SHA-256 implementationbrian m. carlson, Oct 25, 2018
  2. 01/12 sha1-file: rename algorithm to "sha1"brian m. carlson, Oct 25, 2018
  3. 02/12 sha1-file: provide functions to look up hash algorithmsbrian m. carlson, Oct 25, 2018
  4. 03/12 hex: introduce functions to print arbitrary hashesbrian m. carlson, Oct 25, 2018
  5. 04/12 cache: make hashcmp and hasheq work with larger hashesbrian m. carlson, Oct 25, 2018
  6. 05/12 t: add basic tests for our SHA-1 implementationbrian m. carlson, Oct 25, 2018
  7. 06/12 t: make the sha1 test-tool helper genericbrian m. carlson, Oct 25, 2018
  8. 07/12 sha1-file: add a constant for hash block sizebrian m. carlson, Oct 25, 2018
  9. 08/12 t/helper: add a test helper to compute hash speedbrian m. carlson, Oct 25, 2018
  10. 09/12 commit-graph: convert to using the_hash_algobrian m. carlson, Oct 25, 2018
  11. 10/12 Add a base implementation of SHA-256 supportbrian m. carlson, Oct 25, 2018
  12. Carlo ArenasOct 25, 2018
  13. brian m. carlsonOct 28, 2018
  14. Junio C HamanoOct 29, 2018
  15. brian m. carlsonOct 31, 2018
  16. Junio C HamanoNov 1, 2018
  17. Christian CouderOct 27, 2018
  18. 11/12 sha256: add an SHA-256 implementation using libgcryptbrian m. carlson, Oct 25, 2018
  19. 12/12 hash: add an SHA-256 implementation using OpenSSLbrian m. carlson, Oct 25, 2018
  20. 00/12 Base SHA-256 implementationbrian m. carlson, Nov 4, 2018
  21. 01/12 sha1-file: rename algorithm to "sha1"brian m. carlson, Nov 4, 2018
  22. Ævar Arnfjörð BjarmasonNov 5, 2018
  23. 02/12 sha1-file: provide functions to look up hash algorithmsbrian m. carlson, Nov 4, 2018
  24. Derrick StoleeNov 13, 2018
  25. Duy NguyenNov 13, 2018
  26. brian m. carlsonNov 14, 2018
  27. Ramsay JonesNov 14, 2018
  28. Ramsay JonesNov 14, 2018
  29. Jeff KingNov 14, 2018
  30. brian m. carlsonNov 14, 2018
  31. Ramsay JonesNov 14, 2018
  32. 03/12 hex: introduce functions to print arbitrary hashesbrian m. carlson, Nov 4, 2018
  33. 05/12 t: add basic tests for our SHA-1 implementationbrian m. carlson, Nov 4, 2018
  34. 04/12 cache: make hashcmp and hasheq work with larger hashesbrian m. carlson, Nov 4, 2018
  35. 07/12 sha1-file: add a constant for hash block sizebrian m. carlson, Nov 4, 2018
  36. 06/12 t: make the sha1 test-tool helper genericbrian m. carlson, Nov 4, 2018
  37. 08/12 t/helper: add a test helper to compute hash speedbrian m. carlson, Nov 4, 2018
  38. 09/12 commit-graph: convert to using the_hash_algobrian m. carlson, Nov 4, 2018
  39. 10/12 Add a base implementation of SHA-256 supportbrian m. carlson, Nov 4, 2018
  40. Ævar Arnfjörð BjarmasonNov 5, 2018
  41. brian m. carlsonNov 7, 2018
  42. Ævar Arnfjörð BjarmasonNov 10, 2018
  43. 11/12 sha256: add an SHA-256 implementation using libgcryptbrian m. carlson, Nov 4, 2018
  44. 12/12 hash: add an SHA-256 implementation using OpenSSLbrian m. carlson, Nov 4, 2018
  45. Junio C HamanoNov 5, 2018
  46. 00/12 Base SHA-256 implementationbrian m. carlson, Nov 14, 2018
  47. 01/12 sha1-file: rename algorithm to "sha1"brian m. carlson, Nov 14, 2018
  48. 02/12 sha1-file: provide functions to look up hash algorithmsbrian m. carlson, Nov 14, 2018
  49. 03/12 hex: introduce functions to print arbitrary hashesbrian m. carlson, Nov 14, 2018
  50. 04/12 cache: make hashcmp and hasheq work with larger hashesbrian m. carlson, Nov 14, 2018
  51. 06/12 t: make the sha1 test-tool helper genericbrian m. carlson, Nov 14, 2018
  52. 05/12 t: add basic tests for our SHA-1 implementationbrian m. carlson, Nov 14, 2018
  53. 07/12 sha1-file: add a constant for hash block sizebrian m. carlson, Nov 14, 2018
  54. 08/12 t/helper: add a test helper to compute hash speedbrian m. carlson, Nov 14, 2018
  55. 09/12 commit-graph: convert to using the_hash_algobrian m. carlson, Nov 14, 2018
  56. 10/12 Add a base implementation of SHA-256 supportbrian m. carlson, Nov 14, 2018
  57. 11/12 sha256: add an SHA-256 implementation using libgcryptbrian m. carlson, Nov 14, 2018
  58. 12/12 hash: add an SHA-256 implementation using OpenSSLbrian m. carlson, Nov 14, 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.