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 15/16] Remove unneeded *_oid functions.
Date: Wed, 22 Apr 2015 23:24:20 +0000 [thread overview]
Message-ID: <1429745061-295908-16-git-send-email-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <1429745061-295908-1-git-send-email-sandals@crustytoothpaste.net>
While these functions were needed during the intermediate steps of
converting for_each_ref and friends to struct object_id, there is no
longer any need to have these wrapper functions. Update each of the
functions that the wrapper functions call and remove the _oid wrapper
functions themselves.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
builtin/rev-parse.c | 27 +++++++++++----------------
builtin/show-ref.c | 23 +++++++++--------------
log-tree.c | 19 +++++++------------
reachable.c | 13 ++++---------
shallow.c | 33 ++++++++++-----------------------
5 files changed, 41 insertions(+), 74 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4aa7a25..b623239 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -190,19 +190,14 @@ static int show_default(void)
return 0;
}
-static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
{
if (ref_excluded(ref_excludes, refname))
return 0;
- show_rev(NORMAL, sha1, refname);
+ show_rev(NORMAL, oid->hash, refname);
return 0;
}
-static int show_reference_oid(const char *refname, const struct object_id *oid, int flag, void *cb_data)
-{
- return show_reference(refname, oid->hash, flag, cb_data);
-}
-
static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
{
show_rev(REVERSED, oid->hash, refname);
@@ -657,7 +652,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--all")) {
- for_each_ref(show_reference_oid, NULL);
+ for_each_ref(show_reference, NULL);
continue;
}
if (starts_with(arg, "--disambiguate=")) {
@@ -665,45 +660,45 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--bisect")) {
- for_each_ref_in("refs/bisect/bad", show_reference_oid, NULL);
+ for_each_ref_in("refs/bisect/bad", show_reference, NULL);
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
if (starts_with(arg, "--branches=")) {
- for_each_glob_ref_in(show_reference_oid, arg + 11,
+ for_each_glob_ref_in(show_reference, arg + 11,
"refs/heads/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--branches")) {
- for_each_branch_ref(show_reference_oid, NULL);
+ for_each_branch_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--tags=")) {
- for_each_glob_ref_in(show_reference_oid, arg + 7,
+ for_each_glob_ref_in(show_reference, arg + 7,
"refs/tags/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--tags")) {
- for_each_tag_ref(show_reference_oid, NULL);
+ for_each_tag_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--glob=")) {
- for_each_glob_ref(show_reference_oid, arg + 7, NULL);
+ for_each_glob_ref(show_reference, arg + 7, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--remotes=")) {
- for_each_glob_ref_in(show_reference_oid, arg + 10,
+ for_each_glob_ref_in(show_reference, arg + 10,
"refs/remotes/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--remotes")) {
- for_each_remote_ref(show_reference_oid, NULL);
+ for_each_remote_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 6731721..2d2267e 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -26,10 +26,10 @@ static void show_one(const char *refname, const unsigned char *sha1)
printf("%s %s\n", hex, refname);
}
-static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
+static int show_ref(const char *refname, const struct object_id *oid, int flag, void *cbdata)
{
const char *hex;
- unsigned char peeled[20];
+ struct object_id peeled;
if (show_head && !strcmp(refname, "HEAD"))
goto match;
@@ -69,30 +69,25 @@ match:
* detect and return error if the repository is corrupt and
* ref points at a nonexistent object.
*/
- if (!has_sha1_file(sha1))
+ if (!has_sha1_file(oid->hash))
die("git show-ref: bad ref %s (%s)", refname,
- sha1_to_hex(sha1));
+ oid_to_hex(oid));
if (quiet)
return 0;
- show_one(refname, sha1);
+ show_one(refname, oid->hash);
if (!deref_tags)
return 0;
- if (!peel_ref(refname, peeled)) {
- hex = find_unique_abbrev(peeled, abbrev);
+ if (!peel_ref(refname, peeled.hash)) {
+ hex = find_unique_abbrev(peeled.hash, abbrev);
printf("%s %s^{}\n", hex, refname);
}
return 0;
}
-static int show_ref_oid(const char *refname, const struct object_id *oid, int flag, void *cbdata)
-{
- return show_ref(refname, oid->hash, flag, cbdata);
-}
-
static int add_existing(const char *refname, const struct object_id *oid, int flag, void *cbdata)
{
struct string_list *list = (struct string_list *)cbdata;
@@ -230,8 +225,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
}
if (show_head)
- head_ref(show_ref_oid, NULL);
- for_each_ref(show_ref_oid, NULL);
+ head_ref(show_ref, NULL);
+ for_each_ref(show_ref, NULL);
if (!found_match) {
if (verify && !quiet)
die("No match");
diff --git a/log-tree.c b/log-tree.c
index acbc859..64768f7 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -87,26 +87,26 @@ const struct name_decoration *get_name_decoration(const struct object *obj)
return lookup_decoration(&name_decoration, obj);
}
-static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
+static int add_ref_decoration(const char *refname, const struct object_id *oid, int flags, void *cb_data)
{
struct object *obj;
enum decoration_type type = DECORATION_NONE;
if (starts_with(refname, "refs/replace/")) {
- unsigned char original_sha1[20];
+ struct object_id original_oid;
if (!check_replace_refs)
return 0;
- if (get_sha1_hex(refname + 13, original_sha1)) {
+ if (get_oid_hex(refname + 13, &original_oid)) {
warning("invalid replace ref %s", refname);
return 0;
}
- obj = parse_object(original_sha1);
+ obj = parse_object(original_oid.hash);
if (obj)
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
return 0;
}
- obj = parse_object(sha1);
+ obj = parse_object(oid->hash);
if (!obj)
return 0;
@@ -135,11 +135,6 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
return 0;
}
-static int add_ref_decoration_oid(const char *refname, const struct object_id *oid, int flags, void *cb_data)
-{
- return add_ref_decoration(refname, oid->hash, flags, cb_data);
-}
-
static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
{
struct commit *commit = lookup_commit(graft->oid.hash);
@@ -154,8 +149,8 @@ void load_ref_decorations(int flags)
static int loaded;
if (!loaded) {
loaded = 1;
- for_each_ref(add_ref_decoration_oid, &flags);
- head_ref(add_ref_decoration_oid, &flags);
+ for_each_ref(add_ref_decoration, &flags);
+ head_ref(add_ref_decoration, &flags);
for_each_commit_graft(add_graft_decoration, NULL);
}
}
diff --git a/reachable.c b/reachable.c
index b2ca0c3..8715eb9 100644
--- a/reachable.c
+++ b/reachable.c
@@ -22,9 +22,9 @@ static void update_progress(struct connectivity_progress *cp)
display_progress(cp->progress, cp->count);
}
-static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+static int add_one_ref(const char *path, const struct object_id *oid, int flag, void *cb_data)
{
- struct object *object = parse_object_or_die(sha1, path);
+ struct object *object = parse_object_or_die(oid->hash, path);
struct rev_info *revs = (struct rev_info *)cb_data;
add_pending_object(revs, object, "");
@@ -32,11 +32,6 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
return 0;
}
-static int add_one_ref_oid(const char *path, const struct object_id *oid, int flag, void *cb_data)
-{
- return add_one_ref(path, oid->hash, flag, cb_data);
-}
-
/*
* The traversal will have already marked us as SEEN, so we
* only need to handle any progress reporting here.
@@ -173,10 +168,10 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
add_index_objects_to_pending(revs, 0);
/* Add all external refs */
- for_each_ref(add_one_ref_oid, revs);
+ for_each_ref(add_one_ref, revs);
/* detached HEAD is not included in the list above */
- head_ref(add_one_ref_oid, revs);
+ head_ref(add_one_ref, revs);
/* Add all reflog info */
if (mark_reflog)
diff --git a/shallow.c b/shallow.c
index 6511bbb..1c6de02 100644
--- a/shallow.c
+++ b/shallow.c
@@ -476,10 +476,10 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
}
static int mark_uninteresting(const char *refname,
- const unsigned char *sha1,
+ const struct object_id *oid,
int flags, void *cb_data)
{
- struct commit *commit = lookup_commit_reference_gently(sha1, 1);
+ struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
if (!commit)
return 0;
commit->object.flags |= UNINTERESTING;
@@ -487,13 +487,6 @@ static int mark_uninteresting(const char *refname,
return 0;
}
-static int mark_uninteresting_oid(const char *refname,
- const struct object_id *oid,
- int flags, void *cb_data)
-{
- return mark_uninteresting(refname, oid->hash, flags, cb_data);
-}
-
static void post_assign_shallow(struct shallow_info *info,
struct ref_bitmap *ref_bitmap,
int *ref_status);
@@ -549,8 +542,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
* connect to old refs. If not (e.g. force ref updates) it'll
* have to go down to the current shallow commits.
*/
- head_ref(mark_uninteresting_oid, NULL);
- for_each_ref(mark_uninteresting_oid, NULL);
+ head_ref(mark_uninteresting, NULL);
+ for_each_ref(mark_uninteresting, NULL);
/* Mark potential bottoms so we won't go out of bound */
for (i = 0; i < nr_shallow; i++) {
@@ -592,22 +585,16 @@ struct commit_array {
};
static int add_ref(const char *refname,
- const unsigned char *sha1, int flags, void *cb_data)
+ const struct object_id *oid, int flags, void *cb_data)
{
struct commit_array *ca = cb_data;
ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
- ca->commits[ca->nr] = lookup_commit_reference_gently(sha1, 1);
+ ca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);
if (ca->commits[ca->nr])
ca->nr++;
return 0;
}
-static int add_ref_oid(const char *refname,
- const struct object_id *oid, int flags, void *cb_data)
-{
- return add_ref(refname, oid->hash, flags, cb_data);
-}
-
static void update_refstatus(int *ref_status, int nr, uint32_t *bitmap)
{
int i;
@@ -654,8 +641,8 @@ static void post_assign_shallow(struct shallow_info *info,
info->nr_theirs = dst;
memset(&ca, 0, sizeof(ca));
- head_ref(add_ref_oid, &ca);
- for_each_ref(add_ref_oid, &ca);
+ head_ref(add_ref, &ca);
+ for_each_ref(add_ref, &ca);
/* Remove unreachable shallow commits from "ours" */
for (i = dst = 0; i < info->nr_ours; i++) {
@@ -688,8 +675,8 @@ int delayed_reachability_test(struct shallow_info *si, int c)
if (!si->commits) {
struct commit_array ca;
memset(&ca, 0, sizeof(ca));
- head_ref(add_ref_oid, &ca);
- for_each_ref(add_ref_oid, &ca);
+ head_ref(add_ref, &ca);
+ for_each_ref(add_ref, &ca);
si->commits = ca.commits;
si->nr_commits = ca.nr;
}
--
2.3.5
next prev 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 ` brian m. carlson [this message]
2015-04-22 23:24 ` [PATCH v2 16/16] refs: convert struct ref_lock to struct object_id brian m. carlson
2015-04-26 20:26 ` [PATCH v2 00/16] Convert parts of refs.c " 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-16-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).