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>
Subject: [PATCH 14/24] refs: convert peel_ref to struct object_id
Date: Sun, 1 Oct 2017 22:08:21 +0000 [thread overview]
Message-ID: <20171001220831.214705-15-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20171001220831.214705-1-sandals@crustytoothpaste.net>
Convert peel_ref (and its corresponding backend) to struct object_id.
This transformation was done with an update to the declaration,
definition, 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 <sandals@crustytoothpaste.net>
---
builtin/describe.c | 2 +-
builtin/pack-objects.c | 4 ++--
builtin/show-ref.c | 2 +-
refs.c | 8 ++++----
refs.h | 4 ++--
refs/files-backend.c | 8 ++++----
refs/packed-backend.c | 4 ++--
refs/refs-internal.h | 2 +-
t/helper/test-ref-store.c | 6 +++---
upload-pack.c | 2 +-
10 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 29075dbd0f..352f8821fd 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
}
/* Is it annotated? */
- if (!peel_ref(path, peeled.hash)) {
+ if (!peel_ref(path, &peeled)) {
is_annotated = !!oidcmp(oid, &peeled);
} else {
oidcpy(&peeled, oid);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index cde4c96f3d..a2c6029750 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -562,7 +562,7 @@ static int mark_tagged(const char *path, const struct object_id *oid, int flag,
if (entry)
entry->tagged = 1;
- if (!peel_ref(path, peeled.hash)) {
+ if (!peel_ref(path, &peeled)) {
entry = packlist_find(&to_pack, peeled.hash, NULL);
if (entry)
entry->tagged = 1;
@@ -2371,7 +2371,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,
struct object_id peeled;
if (starts_with(path, "refs/tags/") && /* is a tag? */
- !peel_ref(path, peeled.hash) && /* peelable? */
+ !peel_ref(path, &peeled) && /* peelable? */
packlist_find(&to_pack, peeled.hash, NULL)) /* object packed? */
add_tag_chain(oid);
return 0;
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index cbb8cfc7d2..41e5e71cad 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -38,7 +38,7 @@ static void show_one(const char *refname, const struct object_id *oid)
if (!deref_tags)
return;
- if (!peel_ref(refname, peeled.hash)) {
+ if (!peel_ref(refname, &peeled)) {
hex = find_unique_abbrev(peeled.hash, abbrev);
printf("%s %s^{}\n", hex, refname);
}
diff --git a/refs.c b/refs.c
index c158a2d107..6cbe2c1c6b 100644
--- a/refs.c
+++ b/refs.c
@@ -1676,14 +1676,14 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags)
}
int refs_peel_ref(struct ref_store *refs, const char *refname,
- unsigned char *sha1)
+ struct object_id *oid)
{
- return refs->be->peel_ref(refs, refname, sha1);
+ return refs->be->peel_ref(refs, refname, oid);
}
-int peel_ref(const char *refname, unsigned char *sha1)
+int peel_ref(const char *refname, struct object_id *oid)
{
- return refs_peel_ref(get_main_ref_store(), refname, sha1);
+ return refs_peel_ref(get_main_ref_store(), refname, oid);
}
int refs_create_symref(struct ref_store *refs,
diff --git a/refs.h b/refs.h
index 8159b7b067..832ade2b13 100644
--- a/refs.h
+++ b/refs.h
@@ -120,8 +120,8 @@ extern int refs_init_db(struct strbuf *err);
* ultimately resolve to a peelable tag.
*/
int refs_peel_ref(struct ref_store *refs, const char *refname,
- unsigned char *sha1);
-int peel_ref(const char *refname, unsigned char *sha1);
+ struct object_id *oid);
+int peel_ref(const char *refname, struct object_id *oid);
/**
* Resolve refname in the nested "gitlink" repository in the specified
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 148b98490f..a7e4b9e1e9 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -642,7 +642,7 @@ static int lock_raw_ref(struct files_ref_store *refs,
}
static int files_peel_ref(struct ref_store *ref_store,
- const char *refname, unsigned char *sha1)
+ const char *refname, struct object_id *oid)
{
struct files_ref_store *refs =
files_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,
@@ -655,7 +655,7 @@ static int files_peel_ref(struct ref_store *ref_store,
if (ref_iterator_peel(current_ref_iter, &peeled))
return -1;
- hashcpy(sha1, peeled.hash);
+ oidcpy(oid, &peeled);
return 0;
}
@@ -672,10 +672,10 @@ static int files_peel_ref(struct ref_store *ref_store,
* have REF_KNOWS_PEELED.
*/
if (flag & REF_ISPACKED &&
- !refs_peel_ref(refs->packed_ref_store, refname, sha1))
+ !refs_peel_ref(refs->packed_ref_store, refname, oid))
return 0;
- return peel_object(base.hash, sha1);
+ return peel_object(base.hash, oid->hash);
}
struct files_ref_iterator {
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 3bc47ffd5e..d4bb4ba357 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -341,7 +341,7 @@ static int packed_read_raw_ref(struct ref_store *ref_store,
}
static int packed_peel_ref(struct ref_store *ref_store,
- const char *refname, unsigned char *sha1)
+ const char *refname, struct object_id *oid)
{
struct packed_ref_store *refs =
packed_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,
@@ -351,7 +351,7 @@ static int packed_peel_ref(struct ref_store *ref_store,
if (!r || peel_entry(r, 0))
return -1;
- hashcpy(sha1, r->u.value.peeled.hash);
+ oidcpy(oid, &r->u.value.peeled);
return 0;
}
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 6636a13a62..f0bedbd80b 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -549,7 +549,7 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
typedef int pack_refs_fn(struct ref_store *ref_store, unsigned int flags);
typedef int peel_ref_fn(struct ref_store *ref_store,
- const char *refname, unsigned char *sha1);
+ const char *refname, struct object_id *oid);
typedef int create_symref_fn(struct ref_store *ref_store,
const char *ref_target,
const char *refs_heads_master,
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;
}
diff --git a/upload-pack.c b/upload-pack.c
index 030eba5a0c..6d5f3c0d39 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -955,7 +955,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
}
capabilities = NULL;
- if (!peel_ref(refname, peeled.hash))
+ if (!peel_ref(refname, &peeled))
packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
return 0;
}
--
2.14.2.822.g60be5d43e6
next prev parent reply other threads:[~2017-10-01 22:09 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-01 22:08 [PATCH 00/24] object_id part 10 brian m. carlson
2017-10-01 22:08 ` [PATCH 01/24] walker: convert to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 02/24] refs/files-backend: convert struct ref_to_prune to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 03/24] refs: convert delete_ref and refs_delete_ref to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 04/24] refs: convert update_ref and refs_update_ref to use " brian m. carlson
2017-10-02 22:37 ` Stefan Beller
2017-10-03 1:23 ` brian m. carlson
2017-10-02 23:08 ` Brandon Williams
2017-10-01 22:08 ` [PATCH 05/24] refs: update ref transactions " brian m. carlson
2017-10-01 22:08 ` [PATCH 06/24] Convert check_connected " brian m. carlson
2017-10-02 23:00 ` Stefan Beller
2017-10-01 22:08 ` [PATCH 07/24] refs: convert resolve_refdup and refs_resolve_refdup to " brian m. carlson
2017-10-01 22:08 ` [PATCH 08/24] refs: convert read_ref and read_ref_full to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 09/24] refs: convert dwim_ref and expand_ref to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 10/24] builtin/reflog: convert remaining unsigned char uses to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 11/24] refs: convert dwim_log to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 12/24] pack-bitmap: convert traverse_bitmap_commit_list to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 13/24] builtin/pack-objects: convert to struct object_id brian m. carlson
2017-10-02 23:20 ` Stefan Beller
2017-10-01 22:08 ` brian m. carlson [this message]
2017-10-01 22:08 ` [PATCH 15/24] refs: convert read_ref_at " brian m. carlson
2017-10-02 23:26 ` Brandon Williams
2017-10-01 22:08 ` [PATCH 16/24] refs: convert reflog_expire parameter " brian m. carlson
2017-10-01 22:08 ` [PATCH 17/24] sha1_file: convert index_path and index_fd " brian m. carlson
2017-10-01 22:08 ` [PATCH 18/24] Convert remaining callers of resolve_gitlink_ref to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 19/24] refs: convert resolve_gitlink_ref to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 20/24] worktree: convert struct worktree to object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 21/24] refs: convert resolve_ref_unsafe to struct object_id brian m. carlson
2017-10-01 22:08 ` [PATCH 22/24] refs: convert peel_object " brian m. carlson
2017-10-01 22:08 ` [PATCH 23/24] refs: convert read_raw_ref backends " brian m. carlson
2017-10-01 22:08 ` [PATCH 24/24] refs/files-backend: convert static functions to object_id brian m. carlson
2017-10-02 23:34 ` [PATCH 00/24] object_id part 10 Brandon Williams
2017-10-02 23:34 ` Stefan Beller
2017-10-03 1:43 ` 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=20171001220831.214705-15-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 \
/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).