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

[PATCH v2 11/16] builtin/merge: switch to use the_hash_algo

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 16, 2018, 01:28 UTC
Message-ID
<20180716012808.961328-12-sandals@crustytoothpaste.net>
In-Reply-To
<20180716012808.961328-1-sandals@crustytoothpaste.net>
Switch uses of GIT_SHA1_HEXSZ to use the_hash_algo instead.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/merge.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 4a4c09496c..916c9f0569 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1034,6 +1034,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
 	const char *filename;
 	int fd, pos, npos;
 	struct strbuf fetch_head_file = STRBUF_INIT;
+	const unsigned hexsz = the_hash_algo->hexsz;
 
 	if (!merge_names)
 		merge_names = &fetch_head_file;
@@ -1059,16 +1060,16 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
 		else
 			npos = merge_names->len;
 
-		if (npos - pos < GIT_SHA1_HEXSZ + 2 ||
+		if (npos - pos < hexsz + 2 ||
 		    get_oid_hex(merge_names->buf + pos, &oid))
 			commit = NULL; /* bad */
-		else if (memcmp(merge_names->buf + pos + GIT_SHA1_HEXSZ, "\t\t", 2))
+		else if (memcmp(merge_names->buf + pos + hexsz, "\t\t", 2))
 			continue; /* not-for-merge */
 		else {
-			char saved = merge_names->buf[pos + GIT_SHA1_HEXSZ];
-			merge_names->buf[pos + GIT_SHA1_HEXSZ] = '\0';
+			char saved = merge_names->buf[pos + hexsz];
+			merge_names->buf[pos + hexsz] = '\0';
 			commit = get_merge_parent(merge_names->buf + pos);
-			merge_names->buf[pos + GIT_SHA1_HEXSZ] = saved;
+			merge_names->buf[pos + hexsz] = saved;
 		}
 		if (!commit) {
 			if (ptr)
Previous: brian m. carlsonNext: brian m. carlson
Message 12 of 20 in “object_id part 14”
  1. 00/16 object_id part 14brian m. carlson, Jul 16, 2018
  2. 01/16 cache: update object ID functions for the_hash_algobrian m. carlson, Jul 16, 2018
  3. 02/16 tree-walk: replace hard-coded constants with the_hash_algobrian m. carlson, Jul 16, 2018
  4. 03/16 hex: switch to using the_hash_algobrian m. carlson, Jul 16, 2018
  5. 05/16 strbuf: allocate space with GIT_MAX_HEXSZbrian m. carlson, Jul 16, 2018
  6. 04/16 commit: express tree entry constants in terms of the_hash_algobrian m. carlson, Jul 16, 2018
  7. 07/16 refs/files-backend: use the_hash_algo for writing refsbrian m. carlson, Jul 16, 2018
  8. 08/16 builtin/update-index: convert to using the_hash_algobrian m. carlson, Jul 16, 2018
  9. 09/16 builtin/update-index: simplify parsing of cacheinfobrian m. carlson, Jul 16, 2018
  10. 06/16 sha1-name: use the_hash_algo when parsing object namesbrian m. carlson, Jul 16, 2018
  11. 10/16 builtin/fmt-merge-msg: make hash independentbrian m. carlson, Jul 16, 2018
  12. 11/16 builtin/merge: switch to use the_hash_algobrian m. carlson, Jul 16, 2018
  13. 12/16 builtin/merge-recursive: make hash independentbrian m. carlson, Jul 16, 2018
  14. 13/16 diff: switch GIT_SHA1_HEXSZ to use the_hash_algobrian m. carlson, Jul 16, 2018
  15. 14/16 log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexszbrian m. carlson, Jul 16, 2018
  16. 15/16 sha1-file: convert constants to uses of the_hash_algobrian m. carlson, Jul 16, 2018
  17. 16/16 pretty: switch hard-coded constants to the_hash_algobrian m. carlson, Jul 16, 2018
  18. Derrick StoleeJul 16, 2018
  19. Taylor BlauJul 16, 2018
  20. Stefan BellerJul 16, 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.