summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-05-25 18:38:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-25 19:19:30 (GMT)
commit53dc95b5cfa1155c3bf9cf909cfc5cb133add1ac (patch)
tree74b2f617c9282e0b2d6ff644b3896985488adb35 /builtin/remote.c
parente26cdf91c1a836045bcafa3f970b47c0967f3062 (diff)
downloadgit-53dc95b5cfa1155c3bf9cf909cfc5cb133add1ac.zip
git-53dc95b5cfa1155c3bf9cf909cfc5cb133add1ac.tar.gz
git-53dc95b5cfa1155c3bf9cf909cfc5cb133add1ac.tar.bz2
builtin/remote: rewrite functions to take object_id arguments
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r--builtin/remote.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index ab39fea..f4a6ec9 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -554,20 +554,20 @@ struct rename_info {
};
static int read_remote_branches(const char *refname,
- const unsigned char *sha1, int flags, void *cb_data)
+ const struct object_id *oid, int flags, void *cb_data)
{
struct rename_info *rename = cb_data;
struct strbuf buf = STRBUF_INIT;
struct string_list_item *item;
int flag;
- unsigned char orig_sha1[20];
+ struct object_id orig_oid;
const char *symref;
strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
if (starts_with(refname, buf.buf)) {
item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
- orig_sha1, &flag);
+ orig_oid.hash, &flag);
if (flag & REF_ISSYMREF)
item->util = xstrdup(symref);
else
@@ -620,8 +620,6 @@ static int mv(int argc, const char **argv)
struct string_list remote_branches = STRING_LIST_INIT_NODUP;
struct rename_info rename;
int i, refspec_updated = 0;
- struct each_ref_fn_sha1_adapter wrapped_read_remote_branches =
- {read_remote_branches, &rename};
if (argc != 3)
usage_with_options(builtin_remote_rename_usage, options);
@@ -699,13 +697,13 @@ static int mv(int argc, const char **argv)
* First remove symrefs, then rename the rest, finally create
* the new symrefs.
*/
- for_each_ref(each_ref_fn_adapter, &wrapped_read_remote_branches);
+ for_each_ref(read_remote_branches, &rename);
for (i = 0; i < remote_branches.nr; i++) {
struct string_list_item *item = remote_branches.items + i;
int flag = 0;
- unsigned char sha1[20];
+ struct object_id oid;
- read_ref_full(item->string, RESOLVE_REF_READING, sha1, &flag);
+ read_ref_full(item->string, RESOLVE_REF_READING, oid.hash, &flag);
if (!(flag & REF_ISSYMREF))
continue;
if (delete_ref(item->string, NULL, REF_NODEREF))
@@ -866,7 +864,7 @@ static void free_remote_ref_states(struct ref_states *states)
}
static int append_ref_to_tracked_list(const char *refname,
- const unsigned char *sha1, int flags, void *cb_data)
+ const struct object_id *oid, int flags, void *cb_data)
{
struct ref_states *states = cb_data;
struct refspec refspec;
@@ -909,10 +907,7 @@ static int get_remote_ref_states(const char *name,
if (query & GET_PUSH_REF_STATES)
get_push_ref_states(remote_refs, states);
} else {
- struct each_ref_fn_sha1_adapter wrapped_append_ref_to_tracked_list =
- {append_ref_to_tracked_list, states};
-
- for_each_ref(each_ref_fn_adapter, &wrapped_append_ref_to_tracked_list);
+ for_each_ref(append_ref_to_tracked_list, states);
string_list_sort(&states->tracked);
get_push_ref_states_noquery(states);
}