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: "Eric Sunshine" <sunshine@sunshineco.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"René Scharfe" <l.s.r@web.de>, "Jeff King" <peff@peff.net>
Subject: [PATCH v2 31/35] builtin/difftool: use parse_oid_hex
Date: Tue, 19 Feb 2019 00:05:22 +0000	[thread overview]
Message-ID: <20190219000526.476553-32-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20190219000526.476553-1-sandals@crustytoothpaste.net>

Instead of using get_oid_hex and adding constants to the result, use
parse_oid_hex to make this code independent of the hash size.

Additionally, correct a typo that would cause us to print one too few
characters on error, since we will already have incremented the pointer
to point to the beginning of the object ID before we get to printing the
error message.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/difftool.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/builtin/difftool.c b/builtin/difftool.c
index a3ea60ea71..5fa83f481e 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -65,14 +65,12 @@ static int parse_index_info(char *p, int *mode1, int *mode2,
 	*mode2 = (int)strtol(p + 1, &p, 8);
 	if (*p != ' ')
 		return error("expected ' ', got '%c'", *p);
-	if (get_oid_hex(++p, oid1))
-		return error("expected object ID, got '%s'", p + 1);
-	p += GIT_SHA1_HEXSZ;
+	if (parse_oid_hex(++p, oid1, (const char **)&p))
+		return error("expected object ID, got '%s'", p);
 	if (*p != ' ')
 		return error("expected ' ', got '%c'", *p);
-	if (get_oid_hex(++p, oid2))
-		return error("expected object ID, got '%s'", p + 1);
-	p += GIT_SHA1_HEXSZ;
+	if (parse_oid_hex(++p, oid2, (const char **)&p))
+		return error("expected object ID, got '%s'", p);
 	if (*p != ' ')
 		return error("expected ' ', got '%c'", *p);
 	*status = *++p;

  parent reply	other threads:[~2019-02-19  0:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19  0:04 [PATCH v2 00/35] Hash function transition part 16 brian m. carlson
2019-02-19  0:04 ` [PATCH v2 01/35] t/lib-submodule-update: use appropriate length constant brian m. carlson
2019-02-19  0:04 ` [PATCH v2 02/35] khash: move oid hash table definition brian m. carlson
2019-02-19  0:04 ` [PATCH v2 03/35] pack-bitmap: make bitmap header handling hash agnostic brian m. carlson
2019-02-19  0:04 ` [PATCH v2 04/35] pack-bitmap: convert struct stored_bitmap to object_id brian m. carlson
2019-02-19  0:04 ` [PATCH v2 05/35] pack-bitmap: replace sha1_to_hex brian m. carlson
2019-02-19  0:04 ` [PATCH v2 06/35] pack-bitmap: switch hard-coded constants to the_hash_algo brian m. carlson
2019-02-19  0:04 ` [PATCH v2 07/35] pack-bitmap: switch hash tables to use struct object_id brian m. carlson
2019-02-19  0:04 ` [PATCH v2 08/35] submodule: avoid hard-coded constants brian m. carlson
2019-02-19  0:05 ` [PATCH v2 09/35] notes-merge: switch to use the_hash_algo brian m. carlson
2019-02-19  0:05 ` [PATCH v2 10/35] notes: make hash size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 11/35] notes: replace sha1_to_hex brian m. carlson
2019-02-19  0:05 ` [PATCH v2 12/35] object-store: rename and expand packed_git's sha1 member brian m. carlson
2019-02-19  0:05 ` [PATCH v2 13/35] builtin/name-rev: make hash-size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 14/35] fast-import: " brian m. carlson
2019-02-19  0:05 ` [PATCH v2 15/35] fast-import: replace sha1_to_hex brian m. carlson
2019-02-19  0:05 ` [PATCH v2 16/35] builtin/am: make hash size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 17/35] builtin/pull: make hash-size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 18/35] http-push: convert to use the_hash_algo brian m. carlson
2019-02-19  0:05 ` [PATCH v2 19/35] http-backend: allow 64-character hex names brian m. carlson
2019-02-19  0:05 ` [PATCH v2 20/35] http-push: remove remaining uses of sha1_to_hex brian m. carlson
2019-02-19  0:05 ` [PATCH v2 21/35] http-walker: replace sha1_to_hex brian m. carlson
2019-02-19  0:05 ` [PATCH v2 22/35] http: replace hard-coded constant with the_hash_algo brian m. carlson
2019-02-19  0:05 ` [PATCH v2 23/35] http: compute hash of downloaded objects using the_hash_algo brian m. carlson
2019-02-19  0:05 ` [PATCH v2 24/35] http: replace sha1_to_hex brian m. carlson
2019-02-19  0:05 ` [PATCH v2 25/35] remote-curl: make hash size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 26/35] hash: add a function to lookup hash algorithm by length brian m. carlson
2019-02-19  0:05 ` [PATCH v2 27/35] get-tar-commit-id: parse comment record brian m. carlson
2019-02-19  0:05 ` [PATCH v2 28/35] builtin/get-tar-commit-id: make hash size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 29/35] archive: convert struct archiver_args to object_id brian m. carlson
2019-02-19  0:05 ` [PATCH v2 30/35] refspec: make hash size independent brian m. carlson
2019-02-19  0:05 ` brian m. carlson [this message]
2019-02-19  0:05 ` [PATCH v2 32/35] dir: make untracked cache extension " brian m. carlson
2019-02-19  0:05 ` [PATCH v2 33/35] read-cache: read data in a hash-independent way brian m. carlson
2019-02-19  0:05 ` [PATCH v2 34/35] Git.pm: make hash size independent brian m. carlson
2019-02-19  0:05 ` [PATCH v2 35/35] gitweb: " brian m. carlson

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=20190219000526.476553-32-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --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).