Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Derrick Stolee <stolee@gmail.com>,
	Stefan Beller <sbeller@google.com>,
	Brandon Williams <bmwill@google.com>,
	Jacob Keller <jacob.keller@gmail.com>
Subject: [PATCH v2 11/16] builtin/merge: switch to use the_hash_algo
Date: Mon, 16 Jul 2018 01:28:03 +0000	[thread overview]
Message-ID: <20180716012808.961328-12-sandals@crustytoothpaste.net> (raw)
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)

  parent reply	other threads:[~2018-07-16  1:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  1:27 [PATCH v2 00/16] object_id part 14 brian m. carlson
2018-07-16  1:27 ` [PATCH v2 01/16] cache: update object ID functions for the_hash_algo brian m. carlson
2018-07-16  1:27 ` [PATCH v2 02/16] tree-walk: replace hard-coded constants with the_hash_algo brian m. carlson
2018-07-16  1:27 ` [PATCH v2 03/16] hex: switch to using the_hash_algo brian m. carlson
2018-07-16  1:27 ` [PATCH v2 04/16] commit: express tree entry constants in terms of the_hash_algo brian m. carlson
2018-07-16  1:27 ` [PATCH v2 05/16] strbuf: allocate space with GIT_MAX_HEXSZ brian m. carlson
2018-07-16  1:27 ` [PATCH v2 06/16] sha1-name: use the_hash_algo when parsing object names brian m. carlson
2018-07-16  1:27 ` [PATCH v2 07/16] refs/files-backend: use the_hash_algo for writing refs brian m. carlson
2018-07-16  1:28 ` [PATCH v2 08/16] builtin/update-index: convert to using the_hash_algo brian m. carlson
2018-07-16  1:28 ` [PATCH v2 09/16] builtin/update-index: simplify parsing of cacheinfo brian m. carlson
2018-07-16  1:28 ` [PATCH v2 10/16] builtin/fmt-merge-msg: make hash independent brian m. carlson
2018-07-16  1:28 ` brian m. carlson [this message]
2018-07-16  1:28 ` [PATCH v2 12/16] builtin/merge-recursive: " brian m. carlson
2018-07-16  1:28 ` [PATCH v2 13/16] diff: switch GIT_SHA1_HEXSZ to use the_hash_algo brian m. carlson
2018-07-16  1:28 ` [PATCH v2 14/16] log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz brian m. carlson
2018-07-16  1:28 ` [PATCH v2 15/16] sha1-file: convert constants to uses of the_hash_algo brian m. carlson
2018-07-16  1:28 ` [PATCH v2 16/16] pretty: switch hard-coded constants to the_hash_algo brian m. carlson
2018-07-16 14:49 ` [PATCH v2 00/16] object_id part 14 Derrick Stolee
2018-07-16 15:21 ` Taylor Blau
2018-07-16 18:04   ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180716012808.961328-12-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.keller@gmail.com \
    --cc=sbeller@google.com \
    --cc=stolee@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox