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>,
	Junio C Hamano <gitster@pobox.com>,
	"Kyle J. McKay" <mackyle@gmail.com>,
	Ronnie Sahlberg <sahlberg@google.com>
Subject: [PATCH v2 16/16] refs: convert struct ref_lock to struct object_id
Date: Wed, 22 Apr 2015 23:24:21 +0000	[thread overview]
Message-ID: <1429745061-295908-17-git-send-email-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <1429745061-295908-1-git-send-email-sandals@crustytoothpaste.net>

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 refs.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/refs.c b/refs.c
index 9e61b32..6c04189 100644
--- a/refs.c
+++ b/refs.c
@@ -10,7 +10,7 @@ struct ref_lock {
 	char *ref_name;
 	char *orig_ref_name;
 	struct lock_file *lk;
-	unsigned char old_sha1[20];
+	struct object_id old_oid;
 	int lock_fd;
 };
 
@@ -2159,16 +2159,16 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
 {
 	if (read_ref_full(lock->ref_name,
 			  mustexist ? RESOLVE_REF_READING : 0,
-			  lock->old_sha1, NULL)) {
+			  lock->old_oid.hash, NULL)) {
 		int save_errno = errno;
 		error("Can't verify ref %s", lock->ref_name);
 		unlock_ref(lock);
 		errno = save_errno;
 		return NULL;
 	}
-	if (hashcmp(lock->old_sha1, old_sha1)) {
+	if (hashcmp(lock->old_oid.hash, old_sha1)) {
 		error("Ref %s is at %s but expected %s", lock->ref_name,
-			sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1));
+			oid_to_hex(&lock->old_oid), sha1_to_hex(old_sha1));
 		unlock_ref(lock);
 		errno = EBUSY;
 		return NULL;
@@ -2313,7 +2313,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 	}
 
 	refname = resolve_ref_unsafe(refname, resolve_flags,
-				     lock->old_sha1, &type);
+				     lock->old_oid.hash, &type);
 	if (!refname && errno == EISDIR) {
 		/* we are trying to lock foo but we used to
 		 * have foo/bar which now does not exist;
@@ -2327,7 +2327,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 			goto error_return;
 		}
 		refname = resolve_ref_unsafe(orig_refname, resolve_flags,
-					     lock->old_sha1, &type);
+					     lock->old_oid.hash, &type);
 	}
 	if (type_p)
 	    *type_p = type;
@@ -2343,7 +2343,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 	 * refname, nor a packed ref whose name is a proper prefix of
 	 * our refname.
 	 */
-	if (is_null_sha1(lock->old_sha1) &&
+	if (is_null_oid(&lock->old_oid) &&
 	     !is_refname_available(refname, skip, get_packed_refs(&ref_cache))) {
 		last_errno = ENOTDIR;
 		goto error_return;
@@ -2849,7 +2849,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
 		error("unable to lock %s for update", newrefname);
 		goto rollback;
 	}
-	hashcpy(lock->old_sha1, orig_sha1);
+	hashcpy(lock->old_oid.hash, orig_sha1);
 	if (write_ref_sha1(lock, orig_sha1, logmsg)) {
 		error("unable to write current sha1 into %s", newrefname);
 		goto rollback;
@@ -3091,9 +3091,9 @@ static int write_ref_sha1(struct ref_lock *lock,
 		return -1;
 	}
 	clear_loose_ref_cache(&ref_cache);
-	if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
+	if (log_ref_write(lock->ref_name, lock->old_oid.hash, sha1, logmsg) < 0 ||
 	    (strcmp(lock->ref_name, lock->orig_ref_name) &&
-	     log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
+	     log_ref_write(lock->orig_ref_name, lock->old_oid.hash, sha1, logmsg) < 0)) {
 		unlock_ref(lock);
 		return -1;
 	}
@@ -3117,7 +3117,7 @@ static int write_ref_sha1(struct ref_lock *lock,
 					      head_sha1, &head_flag);
 		if (head_ref && (head_flag & REF_ISSYMREF) &&
 		    !strcmp(head_ref, lock->ref_name))
-			log_ref_write("HEAD", lock->old_sha1, sha1, logmsg);
+			log_ref_write("HEAD", lock->old_oid.hash, sha1, logmsg);
 	}
 	if (commit_ref(lock)) {
 		error("Couldn't set %s", lock->ref_name);
@@ -3814,7 +3814,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
 						  (update->flags & REF_NODEREF));
 
 			if (!overwriting_symref
-			    && !hashcmp(update->lock->old_sha1, update->new_sha1)) {
+			    && !hashcmp(update->lock->old_oid.hash, update->new_sha1)) {
 				/*
 				 * The reference already has the desired
 				 * value, so we don't need to write it.
-- 
2.3.5

  parent reply	other threads:[~2015-04-22 23:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 23:24 [PATCH v2 00/16] Convert parts of refs.c to struct object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 01/16] refs: convert struct ref_entry to use " brian m. carlson
2015-04-23  0:52   ` Stefan Beller
2015-04-24 22:36     ` brian m. carlson
2015-04-22 23:24 ` [PATCH v2 02/16] refs: convert for_each_tag_ref to " brian m. carlson
2015-04-23 18:13   ` Stefan Beller
2015-04-23 19:27     ` Jeff King
2015-04-24 22:37       ` brian m. carlson
2015-04-22 23:24 ` [PATCH v2 03/16] refs: convert remaining users of for_each_ref_in to object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 04/16] refs: convert for_each_ref_in_submodule " brian m. carlson
2015-04-22 23:24 ` [PATCH v2 05/16] refs: convert head_ref to struct object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 06/16] refs: convert for_each_ref_submodule " brian m. carlson
2015-04-22 23:24 ` [PATCH v2 07/16] revision: remove unused _oid helper brian m. carlson
2015-04-22 23:24 ` [PATCH v2 08/16] refs: convert for_each_ref to struct object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 09/16] refs: convert for_each_replace_ref " brian m. carlson
2015-04-22 23:24 ` [PATCH v2 10/16] refs: convert namespaced ref iteration functions to object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 11/16] refs: convert for_each_rawref to struct object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 12/16] refs: rename do_for_each_ref_oid to do_for_each_ref brian m. carlson
2015-04-22 23:24 ` [PATCH v2 13/16] refs: convert for_each_reflog to struct object_id brian m. carlson
2015-04-22 23:24 ` [PATCH v2 14/16] refs: rename each_ref_fn_oid to each_ref_fn brian m. carlson
2015-04-22 23:24 ` [PATCH v2 15/16] Remove unneeded *_oid functions brian m. carlson
2015-04-22 23:24 ` brian m. carlson [this message]
2015-04-26 20:26 ` [PATCH v2 00/16] Convert parts of refs.c to struct object_id Michael Haggerty
2015-05-03 21:45   ` 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=1429745061-295908-17-git-send-email-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mackyle@gmail.com \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    --cc=sahlberg@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).