git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 17/25] refs: convert reflog_expire parameter to struct object_id

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 15, 2017, 22:07 UTC
Message-ID
<20171015220712.97308-18-sandals@crustytoothpaste.net>
In-Reply-To
<20171015220712.97308-1-sandals@crustytoothpaste.net>

reflog_expire already used struct object_id internally, but it did not take it as a parameter. Adjust the parameter (and the callers) to pass a pointer to struct object_id instead of a pointer to unsigned char. Remove the temporary inserted earlier as it is no longer required.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/reflog.c      | 6 +++---
 refs.c                | 8 ++++----
 refs.h                | 6 +++---
 refs/files-backend.c  | 9 +++------
 refs/packed-backend.c | 2 +-
 refs/refs-internal.h  | 2 +-
 6 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index cd4c4847b7..ab31a3b6aa 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -589,7 +589,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 		for (i = 0; i < collected.nr; i++) {
 			struct collected_reflog *e = collected.e[i];
 			set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog);
-			status |= reflog_expire(e->reflog, e->oid.hash, flags,
+			status |= reflog_expire(e->reflog, &e->oid, flags,
 						reflog_expiry_prepare,
 						should_expire_reflog_ent,
 						reflog_expiry_cleanup,
@@ -607,7 +607,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 			continue;
 		}
 		set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
-		status |= reflog_expire(ref, oid.hash, flags,
+		status |= reflog_expire(ref, &oid, flags,
 					reflog_expiry_prepare,
 					should_expire_reflog_ent,
 					reflog_expiry_cleanup,
@@ -683,7 +683,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 			cb.cmd.expire_total = 0;
 		}
 
-		status |= reflog_expire(ref, oid.hash, flags,
+		status |= reflog_expire(ref, &oid, flags,
 					reflog_expiry_prepare,
 					should_expire_reflog_ent,
 					reflog_expiry_cleanup,
diff --git a/refs.c b/refs.c
index d19fae5077..37485283c0 100644
--- a/refs.c
+++ b/refs.c
@@ -2010,19 +2010,19 @@ int delete_reflog(const char *refname)
 }
 
 int refs_reflog_expire(struct ref_store *refs,
-		       const char *refname, const unsigned char *sha1,
+		       const char *refname, const struct object_id *oid,
 		       unsigned int flags,
 		       reflog_expiry_prepare_fn prepare_fn,
 		       reflog_expiry_should_prune_fn should_prune_fn,
 		       reflog_expiry_cleanup_fn cleanup_fn,
 		       void *policy_cb_data)
 {
-	return refs->be->reflog_expire(refs, refname, sha1, flags,
+	return refs->be->reflog_expire(refs, refname, oid, flags,
 				       prepare_fn, should_prune_fn,
 				       cleanup_fn, policy_cb_data);
 }
 
-int reflog_expire(const char *refname, const unsigned char *sha1,
+int reflog_expire(const char *refname, const struct object_id *oid,
 		  unsigned int flags,
 		  reflog_expiry_prepare_fn prepare_fn,
 		  reflog_expiry_should_prune_fn should_prune_fn,
@@ -2030,7 +2030,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
 		  void *policy_cb_data)
 {
 	return refs_reflog_expire(get_main_ref_store(),
-				  refname, sha1, flags,
+				  refname, oid, flags,
 				  prepare_fn, should_prune_fn,
 				  cleanup_fn, policy_cb_data);
 }
diff --git a/refs.h b/refs.h
index 5f329d6618..50f6f0dbd7 100644
--- a/refs.h
+++ b/refs.h
@@ -703,20 +703,20 @@ typedef int reflog_expiry_should_prune_fn(struct object_id *ooid,
 typedef void reflog_expiry_cleanup_fn(void *cb_data);
 
 /*
- * Expire reflog entries for the specified reference. sha1 is the old
+ * Expire reflog entries for the specified reference. oid is the old
  * value of the reference. flags is a combination of the constants in
  * enum expire_reflog_flags. The three function pointers are described
  * above. On success, return zero.
  */
 int refs_reflog_expire(struct ref_store *refs,
 		       const char *refname,
-		       const unsigned char *sha1,
+		       const struct object_id *oid,
 		       unsigned int flags,
 		       reflog_expiry_prepare_fn prepare_fn,
 		       reflog_expiry_should_prune_fn should_prune_fn,
 		       reflog_expiry_cleanup_fn cleanup_fn,
 		       void *policy_cb_data);
-int reflog_expire(const char *refname, const unsigned char *sha1,
+int reflog_expire(const char *refname, const struct object_id *oid,
 		  unsigned int flags,
 		  reflog_expiry_prepare_fn prepare_fn,
 		  reflog_expiry_should_prune_fn should_prune_fn,
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 9814cbdcef..3ff5dc5b1c 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2908,7 +2908,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
 }
 
 static int files_reflog_expire(struct ref_store *ref_store,
-			       const char *refname, const unsigned char *sha1,
+			       const char *refname, const struct object_id *oid,
 			       unsigned int flags,
 			       reflog_expiry_prepare_fn prepare_fn,
 			       reflog_expiry_should_prune_fn should_prune_fn,
@@ -2925,7 +2925,6 @@ static int files_reflog_expire(struct ref_store *ref_store,
 	int status = 0;
 	int type;
 	struct strbuf err = STRBUF_INIT;
-	struct object_id oid;
 
 	memset(&cb, 0, sizeof(cb));
 	cb.flags = flags;
@@ -2937,7 +2936,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 	 * reference itself, plus we might need to update the
 	 * reference if --updateref was specified:
 	 */
-	lock = lock_ref_sha1_basic(refs, refname, sha1,
+	lock = lock_ref_sha1_basic(refs, refname, oid->hash,
 				   NULL, NULL, REF_NODEREF,
 				   &type, &err);
 	if (!lock) {
@@ -2975,9 +2974,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 		}
 	}
 
-	hashcpy(oid.hash, sha1);
-
-	(*prepare_fn)(refname, &oid, cb.policy_cb);
+	(*prepare_fn)(refname, oid, cb.policy_cb);
 	refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);
 	(*cleanup_fn)(cb.policy_cb);
 
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 3279d42c5a..4ec9fcacdd 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1519,7 +1519,7 @@ static int packed_delete_reflog(struct ref_store *ref_store,
 }
 
 static int packed_reflog_expire(struct ref_store *ref_store,
-				const char *refname, const unsigned char *sha1,
+				const char *refname, const struct object_id *oid,
 				unsigned int flags,
 				reflog_expiry_prepare_fn prepare_fn,
 				reflog_expiry_should_prune_fn should_prune_fn,
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 951bd340c8..3c4781eb87 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -608,7 +608,7 @@ typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname,
 			     int force_create, struct strbuf *err);
 typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname);
 typedef int reflog_expire_fn(struct ref_store *ref_store,
-			     const char *refname, const unsigned char *sha1,
+			     const char *refname, const struct object_id *oid,
 			     unsigned int flags,
 			     reflog_expiry_prepare_fn prepare_fn,
 			     reflog_expiry_should_prune_fn should_prune_fn,
-- 
2.15.0.rc0.271.g36b669edcc
Previous: brian m. carlsonNext: brian m. carlson
Message 18 of 30 in “object_id part 10”
  1. 00/25 object_id part 10brian m. carlson, Oct 15, 2017
  2. 02/25 refs/files-backend: convert struct ref_to_prune to object_idbrian m. carlson, Oct 15, 2017
  3. 05/25 refs: prevent accidental NULL dereference in write_pseudorefbrian m. carlson, Oct 15, 2017
  4. 06/25 refs: update ref transactions to use struct object_idbrian m. carlson, Oct 15, 2017
  5. 07/25 Convert check_connected to use struct object_idbrian m. carlson, Oct 15, 2017
  6. 08/25 refs: convert resolve_refdup and refs_resolve_refdup to struct object_idbrian m. carlson, Oct 15, 2017
  7. 10/25 refs: convert dwim_ref and expand_ref to struct object_idbrian m. carlson, Oct 15, 2017
  8. 11/25 builtin/reflog: convert remaining unsigned char uses to object_idbrian m. carlson, Oct 15, 2017
  9. 15/25 refs: convert peel_ref to struct object_idbrian m. carlson, Oct 15, 2017
  10. 14/25 builtin/pack-objects: convert to struct object_idbrian m. carlson, Oct 15, 2017
  11. 18/25 sha1_file: convert index_path and index_fd to struct object_idbrian m. carlson, Oct 15, 2017
  12. 23/25 refs: convert peel_object to struct object_idbrian m. carlson, Oct 15, 2017
  13. 24/25 refs: convert read_raw_ref backends to struct object_idbrian m. carlson, Oct 15, 2017
  14. 19/25 Convert remaining callers of resolve_gitlink_ref to object_idbrian m. carlson, Oct 15, 2017
  15. 25/25 refs/files-backend: convert static functions to object_idbrian m. carlson, Oct 15, 2017
  16. 20/25 refs: convert resolve_gitlink_ref to struct object_idbrian m. carlson, Oct 15, 2017
  17. 21/25 worktree: convert struct worktree to object_idbrian m. carlson, Oct 15, 2017
  18. 17/25 refs: convert reflog_expire parameter to struct object_idbrian m. carlson, Oct 15, 2017
  19. 22/25 refs: convert resolve_ref_unsafe to struct object_idbrian m. carlson, Oct 15, 2017
  20. 16/25 refs: convert read_ref_at to struct object_idbrian m. carlson, Oct 15, 2017
  21. 13/25 pack-bitmap: convert traverse_bitmap_commit_list to object_idbrian m. carlson, Oct 15, 2017
  22. 09/25 refs: convert read_ref and read_ref_full to object_idbrian m. carlson, Oct 15, 2017
  23. 12/25 refs: convert dwim_log to struct object_idbrian m. carlson, Oct 15, 2017
  24. 01/25 walker: convert to struct object_idbrian m. carlson, Oct 15, 2017
  25. 03/25 refs: convert delete_ref and refs_delete_ref to struct object_idbrian m. carlson, Oct 15, 2017
  26. 04/25 refs: convert update_ref and refs_update_ref to use struct object_idbrian m. carlson, Oct 15, 2017
  27. Junio C HamanoOct 16, 2017
  28. brian m. carlsonOct 16, 2017
  29. Kevin DaudtOct 16, 2017
  30. Junio C HamanoOct 17, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.