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>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Brandon Williams <bmwill@google.com>,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH v2 18/24] Convert remaining callers of resolve_gitlink_ref to object_id
Date: Mon,  9 Oct 2017 01:11:26 +0000	[thread overview]
Message-ID: <20171009011132.675341-19-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20171009011132.675341-1-sandals@crustytoothpaste.net>

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 diff-lib.c     | 4 ++--
 dir.c          | 8 ++++----
 read-cache.c   | 6 +++---
 unpack-trees.c | 8 ++++----
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 4e0980caa8..af4f1b7865 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -36,7 +36,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
 	if (has_symlink_leading_path(ce->name, ce_namelen(ce)))
 		return 1;
 	if (S_ISDIR(st->st_mode)) {
-		unsigned char sub[20];
+		struct object_id sub;
 
 		/*
 		 * If ce is already a gitlink, we can have a plain
@@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
 		 * a directory --- the blob was removed!
 		 */
 		if (!S_ISGITLINK(ce->ce_mode) &&
-		    resolve_gitlink_ref(ce->name, "HEAD", sub))
+		    resolve_gitlink_ref(ce->name, "HEAD", sub.hash))
 			return 1;
 	}
 	return 0;
diff --git a/dir.c b/dir.c
index 1d17b800cf..a4198ba7fd 100644
--- a/dir.c
+++ b/dir.c
@@ -1390,8 +1390,8 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
 		if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
 			break;
 		if (!(dir->flags & DIR_NO_GITLINKS)) {
-			unsigned char sha1[20];
-			if (resolve_gitlink_ref(dirname, "HEAD", sha1) == 0)
+			struct object_id oid;
+			if (resolve_gitlink_ref(dirname, "HEAD", oid.hash) == 0)
 				return path_untracked;
 		}
 		return path_recurse;
@@ -2279,10 +2279,10 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
 	int ret = 0, original_len = path->len, len, kept_down = 0;
 	int only_empty = (flag & REMOVE_DIR_EMPTY_ONLY);
 	int keep_toplevel = (flag & REMOVE_DIR_KEEP_TOPLEVEL);
-	unsigned char submodule_head[20];
+	struct object_id submodule_head;
 
 	if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
-	    !resolve_gitlink_ref(path->buf, "HEAD", submodule_head)) {
+	    !resolve_gitlink_ref(path->buf, "HEAD", submodule_head.hash)) {
 		/* Do not descend and nuke a nested git work tree. */
 		if (kept_up)
 			*kept_up = 1;
diff --git a/read-cache.c b/read-cache.c
index 65f4fe8375..131485b3a6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -191,7 +191,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
 
 static int ce_compare_gitlink(const struct cache_entry *ce)
 {
-	unsigned char sha1[20];
+	struct object_id oid;
 
 	/*
 	 * We don't actually require that the .git directory
@@ -201,9 +201,9 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
 	 *
 	 * If so, we consider it always to match.
 	 */
-	if (resolve_gitlink_ref(ce->name, "HEAD", sha1) < 0)
+	if (resolve_gitlink_ref(ce->name, "HEAD", oid.hash) < 0)
 		return 0;
-	return hashcmp(sha1, ce->oid.hash);
+	return oidcmp(&oid, &ce->oid);
 }
 
 static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)
diff --git a/unpack-trees.c b/unpack-trees.c
index 71b70ccb12..0dc76eddfe 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1541,15 +1541,15 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
 	int cnt = 0;
 
 	if (S_ISGITLINK(ce->ce_mode)) {
-		unsigned char sha1[20];
-		int sub_head = resolve_gitlink_ref(ce->name, "HEAD", sha1);
+		struct object_id oid;
+		int sub_head = resolve_gitlink_ref(ce->name, "HEAD", oid.hash);
 		/*
 		 * If we are not going to update the submodule, then
 		 * we don't care.
 		 */
-		if (!sub_head && !hashcmp(sha1, ce->oid.hash))
+		if (!sub_head && !oidcmp(&oid, &ce->oid))
 			return 0;
-		return verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),
+		return verify_clean_submodule(sub_head ? NULL : oid_to_hex(&oid),
 					      ce, error_type, o);
 	}
 
-- 
2.14.2.920.gcf0c67979c


  parent reply	other threads:[~2017-10-09  1:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09  1:11 [PATCH v2 00/24] object_id part 10 brian m. carlson
2017-10-09  1:11 ` [PATCH v2 01/24] walker: convert to struct object_id brian m. carlson
2017-10-09 22:37   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 02/24] refs/files-backend: convert struct ref_to_prune to object_id brian m. carlson
2017-10-09 22:38   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 03/24] refs: convert delete_ref and refs_delete_ref to struct object_id brian m. carlson
2017-10-09 22:43   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 04/24] refs: convert update_ref and refs_update_ref to use " brian m. carlson
2017-10-09 22:57   ` Jonathan Nieder
2017-10-11  6:33   ` Michael Haggerty
2017-10-12  8:42     ` brian m. carlson
2017-10-09  1:11 ` [PATCH v2 05/24] refs: update ref transactions " brian m. carlson
2017-10-09 23:13   ` Jonathan Nieder
2017-10-11  6:58   ` Michael Haggerty
2017-10-09  1:11 ` [PATCH v2 06/24] Convert check_connected " brian m. carlson
2017-10-09 23:20   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 07/24] refs: convert resolve_refdup and refs_resolve_refdup to " brian m. carlson
2017-10-09 23:36   ` Jonathan Nieder
2017-10-10  1:16   ` Junio C Hamano
2017-10-09  1:11 ` [PATCH v2 08/24] refs: convert read_ref and read_ref_full to object_id brian m. carlson
2017-10-10  1:35   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 09/24] refs: convert dwim_ref and expand_ref to struct object_id brian m. carlson
2017-10-10  2:03   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 10/24] builtin/reflog: convert remaining unsigned char uses to object_id brian m. carlson
2017-10-10  2:15   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 11/24] refs: convert dwim_log to struct object_id brian m. carlson
2017-10-10  2:18   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 12/24] pack-bitmap: convert traverse_bitmap_commit_list to object_id brian m. carlson
2017-10-10  2:19   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 13/24] builtin/pack-objects: convert to struct object_id brian m. carlson
2017-10-10  2:24   ` Jonathan Nieder
2017-10-09  1:11 ` [PATCH v2 14/24] refs: convert peel_ref " brian m. carlson
2017-10-11  8:00   ` Michael Haggerty
2017-10-09  1:11 ` [PATCH v2 15/24] refs: convert read_ref_at " brian m. carlson
2017-10-09  1:11 ` [PATCH v2 16/24] refs: convert reflog_expire parameter " brian m. carlson
2017-10-09  1:11 ` [PATCH v2 17/24] sha1_file: convert index_path and index_fd " brian m. carlson
2017-10-09  1:11 ` brian m. carlson [this message]
2017-10-09  1:11 ` [PATCH v2 19/24] refs: convert resolve_gitlink_ref " brian m. carlson
2017-10-09  1:11 ` [PATCH v2 20/24] worktree: convert struct worktree to object_id brian m. carlson
2017-10-09  1:11 ` [PATCH v2 21/24] refs: convert resolve_ref_unsafe to struct object_id brian m. carlson
2017-10-11  8:23   ` Michael Haggerty
2017-10-09  1:11 ` [PATCH v2 22/24] refs: convert peel_object " brian m. carlson
2017-10-09  1:11 ` [PATCH v2 23/24] refs: convert read_raw_ref backends " brian m. carlson
2017-10-11  8:30   ` Michael Haggerty
2017-10-09  1:11 ` [PATCH v2 24/24] refs/files-backend: convert static functions to object_id brian m. carlson
2017-10-11  8:36   ` Michael Haggerty
2017-10-09 18:00 ` [PATCH v2 00/24] object_id part 10 Stefan Beller
2017-10-09 22:44 ` Junio C Hamano
2017-10-11 10:05 ` Michael Haggerty
2017-10-11 10:42   ` Junio C Hamano
2017-10-12  8:46   ` brian m. carlson
2017-10-12  9:58     ` Junio C Hamano
2017-10-12 10:22       ` 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=20171009011132.675341-19-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    --cc=sbeller@google.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).