git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH 01/17] cache: update object ID functions for the_hash_algo
Date: Sun,  8 Jul 2018 23:36:22 +0000	[thread overview]
Message-ID: <20180708233638.520172-2-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20180708233638.520172-1-sandals@crustytoothpaste.net>

Update the hashcpy and hashclr functions to use the_hash_algo, since
they are used in a variety of places to copy and manipulate buffers that
need to move data into or out of struct object_id.  Update oidcmp so
that it is implemented on its own and similarly uses the_hash_algo.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 cache.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index d49092d94d..c4a64278a1 100644
--- a/cache.h
+++ b/cache.h
@@ -977,7 +977,7 @@ static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
 
 static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
 {
-	return hashcmp(oid1->hash, oid2->hash);
+	return memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);
 }
 
 static inline int is_null_sha1(const unsigned char *sha1)
@@ -992,7 +992,7 @@ static inline int is_null_oid(const struct object_id *oid)
 
 static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
 {
-	memcpy(sha_dst, sha_src, GIT_SHA1_RAWSZ);
+	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
 }
 
 static inline void oidcpy(struct object_id *dst, const struct object_id *src)
@@ -1009,7 +1009,7 @@ static inline struct object_id *oiddup(const struct object_id *src)
 
 static inline void hashclr(unsigned char *hash)
 {
-	memset(hash, 0, GIT_SHA1_RAWSZ);
+	memset(hash, 0, the_hash_algo->rawsz);
 }
 
 static inline void oidclr(struct object_id *oid)

  reply	other threads:[~2018-07-08 23:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08 23:36 [PATCH 00/17] object_id part 14 brian m. carlson
2018-07-08 23:36 ` brian m. carlson [this message]
2018-07-09  2:38   ` [PATCH 01/17] cache: update object ID functions for the_hash_algo Jacob Keller
2018-07-09  4:05     ` Eric Sunshine
2018-07-09  4:31       ` Jacob Keller
2018-07-09 23:26         ` brian m. carlson
2018-07-08 23:36 ` [PATCH 02/17] tree-walk: replace hard-coded constants with the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 03/17] hex: switch to using the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 04/17] commit: express tree entry constants in terms of the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 05/17] strbuf: allocate space with GIT_MAX_HEXSZ brian m. carlson
2018-07-08 23:36 ` [PATCH 06/17] sha1-name: use the_hash_algo when parsing object names brian m. carlson
2018-07-08 23:36 ` [PATCH 07/17] commit: increase commit message buffer size brian m. carlson
2018-07-09 13:09   ` Derrick Stolee
2018-07-09 17:24     ` Stefan Beller
2018-07-09 17:27       ` Brandon Williams
2018-07-09 17:34         ` Junio C Hamano
2018-07-09 17:36           ` Brandon Williams
2018-07-09 17:45     ` Junio C Hamano
2018-07-09 23:39       ` brian m. carlson
2018-07-10 16:35         ` Junio C Hamano
2018-07-10 18:08         ` Ben Peart
2018-07-11  1:43           ` brian m. carlson
2018-07-11 15:36             ` Junio C Hamano
2018-07-08 23:36 ` [PATCH 08/17] refs/files-backend: use the_hash_algo for writing refs brian m. carlson
2018-07-08 23:36 ` [PATCH 09/17] builtin/update-index: convert to using the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 10/17] builtin/update-index: simplify parsing of cacheinfo brian m. carlson
2018-07-08 23:36 ` [PATCH 11/17] builtin/fmt-merge-msg: make hash independent brian m. carlson
2018-07-08 23:36 ` [PATCH 12/17] builtin/merge: switch to use the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 13/17] builtin/merge-recursive: make hash independent brian m. carlson
2018-07-08 23:36 ` [PATCH 14/17] diff: switch GIT_SHA1_HEXSZ to use the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 15/17] log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz brian m. carlson
2018-07-08 23:36 ` [PATCH 16/17] sha1-file: convert constants to uses of the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 17/17] pretty: switch hard-coded constants to the_hash_algo brian m. carlson
2018-07-09  3:12 ` [PATCH 00/17] object_id part 14 Jacob Keller
2018-07-09 13:12   ` Derrick Stolee
2018-07-14 23:38     ` Michael Haggerty
2018-07-16 21:06       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20180708233638.520172-2-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).