From 2616a5e5089814188a583572bd9bf578b18a2a40 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:06:50 +0000 Subject: refs: convert delete_ref and refs_delete_ref to struct object_id Convert delete_ref and refs_delete_ref to take a pointer to struct object_id. Update the documentation accordingly, including referring to null_oid in lowercase, as it is not a #define constant. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 05d8c4d8af..4624238641 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -218,12 +218,12 @@ static int cmd_delete_ref(struct ref_store *refs, const char **argv) const char *refname = notnull(*argv++, "refname"); const char *sha1_buf = notnull(*argv++, "old-sha1"); unsigned int flags = arg_flags(*argv++, "flags"); - unsigned char old_sha1[20]; + struct object_id old_oid; - if (get_sha1_hex(sha1_buf, old_sha1)) + if (get_oid_hex(sha1_buf, &old_oid)) die("not sha-1"); - return refs_delete_ref(refs, msg, refname, old_sha1, flags); + return refs_delete_ref(refs, msg, refname, &old_oid, flags); } static int cmd_update_ref(struct ref_store *refs, const char **argv) -- cgit v1.2.3 From ae077771b09fac4d663e3f8c039318a97eb3a15b Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:06:51 +0000 Subject: refs: convert update_ref and refs_update_ref to use struct object_id Convert update_ref, refs_update_ref, and write_pseudoref to use struct object_id. Update the existing callers as well. Remove update_ref_oid, as it is no longer needed. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 4624238641..af8dba9560 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -233,15 +233,15 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv) const char *new_sha1_buf = notnull(*argv++, "old-sha1"); const char *old_sha1_buf = notnull(*argv++, "old-sha1"); unsigned int flags = arg_flags(*argv++, "flags"); - unsigned char old_sha1[20]; - unsigned char new_sha1[20]; + struct object_id old_oid; + struct object_id new_oid; - if (get_sha1_hex(old_sha1_buf, old_sha1) || - get_sha1_hex(new_sha1_buf, new_sha1)) + if (get_oid_hex(old_sha1_buf, &old_oid) || + get_oid_hex(new_sha1_buf, &new_oid)) die("not sha-1"); return refs_update_ref(refs, msg, refname, - new_sha1, old_sha1, + &new_oid, &old_oid, flags, UPDATE_REFS_DIE_ON_ERR); } -- cgit v1.2.3 From b420d90980a31246836680b68ca15e0239a8b696 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:07:02 +0000 Subject: refs: convert peel_ref to struct object_id Convert peel_ref (and its corresponding backend) to struct object_id. This transformation was done with an update to the declaration, definition, comments, and test helper and the following semantic patch: @@ expression E1, E2; @@ - peel_ref(E1, E2.hash) + peel_ref(E1, &E2) @@ expression E1, E2; @@ - peel_ref(E1, E2->hash) + peel_ref(E1, E2) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index af8dba9560..cea3285ada 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -72,12 +72,12 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv) static int cmd_peel_ref(struct ref_store *refs, const char **argv) { const char *refname = notnull(*argv++, "refname"); - unsigned char sha1[20]; + struct object_id oid; int ret; - ret = refs_peel_ref(refs, refname, sha1); + ret = refs_peel_ref(refs, refname, &oid); if (!ret) - puts(sha1_to_hex(sha1)); + puts(oid_to_hex(&oid)); return ret; } -- cgit v1.2.3 From 49e61479be913f67e66bb3fdf8de9475c41b58bd Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:07:09 +0000 Subject: refs: convert resolve_ref_unsafe to struct object_id Convert resolve_ref_unsafe to take a pointer to struct object_id by converting one remaining caller to use struct object_id, removing the temporary NULL pointer check in expand_ref, converting the declaration and definition, and applying the following semantic patch: @@ expression E1, E2, E3, E4; @@ - resolve_ref_unsafe(E1, E2, E3.hash, E4) + resolve_ref_unsafe(E1, E2, &E3, E4) @@ expression E1, E2, E3, E4; @@ - resolve_ref_unsafe(E1, E2, E3->hash, E4) + resolve_ref_unsafe(E1, E2, E3, E4) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/helper/test-ref-store.c') diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index cea3285ada..d846c88ed2 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -127,15 +127,15 @@ static int cmd_for_each_ref(struct ref_store *refs, const char **argv) static int cmd_resolve_ref(struct ref_store *refs, const char **argv) { - unsigned char sha1[20]; + struct object_id oid; const char *refname = notnull(*argv++, "refname"); int resolve_flags = arg_flags(*argv++, "resolve-flags"); int flags; const char *ref; ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags, - sha1, &flags); - printf("%s %s 0x%x\n", sha1_to_hex(sha1), ref, flags); + &oid, &flags); + printf("%s %s 0x%x\n", oid_to_hex(&oid), ref, flags); return ref ? 0 : 1; } -- cgit v1.2.3