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

[PATCH v2 8/9] write_packed_entry(): take `object_id` arguments

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Nov 5, 2017, 08:42 UTC
Message-ID
<e397d73256373c319ff79b16ef5fb4a4813d8ff9.1509870243.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1509870243.git.mhagger@alum.mit.edu>

Change `write_packed_entry()` to take `struct object_id *` rather than `unsigned char *` arguments.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs/packed-backend.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 74f1dea0f4..43ad74fc5a 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -961,11 +961,11 @@ static struct ref_iterator *packed_ref_iterator_begin(
  * by the failing call to `fprintf()`.
  */
 static int write_packed_entry(FILE *fh, const char *refname,
-			      const unsigned char *sha1,
-			      const unsigned char *peeled)
+			      const struct object_id *oid,
+			      const struct object_id *peeled)
 {
-	if (fprintf(fh, "%s %s\n", sha1_to_hex(sha1), refname) < 0 ||
-	    (peeled && fprintf(fh, "^%s\n", sha1_to_hex(peeled)) < 0))
+	if (fprintf(fh, "%s %s\n", oid_to_hex(oid), refname) < 0 ||
+	    (peeled && fprintf(fh, "^%s\n", oid_to_hex(peeled)) < 0))
 		return -1;
 
 	return 0;
@@ -1203,8 +1203,8 @@ static int write_with_updates(struct packed_ref_store *refs,
 			int peel_error = ref_iterator_peel(iter, &peeled);
 
 			if (write_packed_entry(out, iter->refname,
-					       iter->oid->hash,
-					       peel_error ? NULL : peeled.hash))
+					       iter->oid,
+					       peel_error ? NULL : &peeled))
 				goto write_error;
 
 			if ((ok = ref_iterator_advance(iter)) != ITER_OK)
@@ -1224,8 +1224,8 @@ static int write_with_updates(struct packed_ref_store *refs,
 						     &peeled);
 
 			if (write_packed_entry(out, update->refname,
-					       update->new_oid.hash,
-					       peel_error ? NULL : peeled.hash))
+					       &update->new_oid,
+					       peel_error ? NULL : &peeled))
 				goto write_error;
 
 			i++;
-- 
2.14.1
Previous: Michael HaggertyNext: Michael Haggerty
Message 4 of 12 in “Tidy up the constants related to ref_update::flags”
  1. 0/9 Tidy up the constants related to ref_update::flagsMichael Haggerty, Nov 5, 2017
  2. 1/9 files_transaction_prepare(): don't leak flags to packed transactionMichael Haggerty, Nov 5, 2017
  3. 7/9 refs: rename constant `REF_ISPRUNING` to `REF_IS_PRUNING`Michael Haggerty, Nov 5, 2017
  4. 8/9 write_packed_entry(): take `object_id` argumentsMichael Haggerty, Nov 5, 2017
  5. 9/9 refs: update some more docs to use "oid" rather than "sha1"Michael Haggerty, Nov 5, 2017
  6. 5/9 refs: tidy up and adjust visibility of the `ref_update` flagsMichael Haggerty, Nov 5, 2017
  7. 6/9 refs: rename constant `REF_NODEREF` to `REF_NO_DEREF`Michael Haggerty, Nov 5, 2017
  8. 2/9 prune_ref(): call `ref_transaction_add_update()` directlyMichael Haggerty, Nov 5, 2017
  9. 3/9 ref_transaction_update(): die on disallowed flagsMichael Haggerty, Nov 5, 2017
  10. Martin ÅgrenNov 7, 2017
  11. Thomas GummererNov 7, 2017
  12. 4/9 ref_transaction_add_update(): remove a checkMichael Haggerty, Nov 5, 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.