summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-05-25 18:38:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-25 19:19:27 (GMT)
commit2b2a5be394bc67bed86bc009195c664dca740bd6 (patch)
tree695bba8905d3f1d806ab329e65d2a297abfc85ac /builtin/rev-parse.c
parent8353847e85128e0d0bbed862889f6f36c608c73b (diff)
downloadgit-2b2a5be394bc67bed86bc009195c664dca740bd6.zip
git-2b2a5be394bc67bed86bc009195c664dca740bd6.tar.gz
git-2b2a5be394bc67bed86bc009195c664dca740bd6.tar.bz2
each_ref_fn: change to take an object_id parameter
Change typedef each_ref_fn to take a "const struct object_id *oid" parameter instead of "const unsigned char *sha1". To aid this transition, implement an adapter that can be used to wrap old-style functions matching the old typedef, which is now called "each_ref_sha1_fn"), and make such functions callable via the new interface. This requires the old function and its cb_data to be wrapped in a "struct each_ref_fn_sha1_adapter", and that object to be used as the cb_data for an adapter function, each_ref_fn_adapter(). This is an enormous diff, but most of it consists of simple, mechanical changes to the sites that call any of the "for_each_ref" family of functions. Subsequent to this change, the call sites can be rewritten one by one to use the new interface. 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/rev-parse.c')
-rw-r--r--builtin/rev-parse.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4d10dd9..e75ce75 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -511,6 +511,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
unsigned int flags = 0;
const char *name = NULL;
struct object_context unused;
+ struct each_ref_fn_sha1_adapter wrapped_show_reference =
+ {show_reference, NULL};
+ struct each_ref_fn_sha1_adapter wrapped_anti_reference =
+ {anti_reference, NULL};
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -652,7 +656,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--all")) {
- for_each_ref(show_reference, NULL);
+ for_each_ref(each_ref_fn_adapter, &wrapped_show_reference);
continue;
}
if (starts_with(arg, "--disambiguate=")) {
@@ -660,45 +664,48 @@ 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, NULL);
- for_each_ref_in("refs/bisect/good", anti_reference, NULL);
+ for_each_ref_in("refs/bisect/bad",
+ each_ref_fn_adapter, &wrapped_show_reference);
+ for_each_ref_in("refs/bisect/good",
+ each_ref_fn_adapter, &wrapped_anti_reference);
continue;
}
if (starts_with(arg, "--branches=")) {
- for_each_glob_ref_in(show_reference, arg + 11,
- "refs/heads/", NULL);
+ for_each_glob_ref_in(each_ref_fn_adapter, arg + 11,
+ "refs/heads/", &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--branches")) {
- for_each_branch_ref(show_reference, NULL);
+ for_each_branch_ref(each_ref_fn_adapter, &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--tags=")) {
- for_each_glob_ref_in(show_reference, arg + 7,
- "refs/tags/", NULL);
+ for_each_glob_ref_in(each_ref_fn_adapter, arg + 7,
+ "refs/tags/", &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--tags")) {
- for_each_tag_ref(show_reference, NULL);
+ for_each_tag_ref(each_ref_fn_adapter, &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--glob=")) {
- for_each_glob_ref(show_reference, arg + 7, NULL);
+ for_each_glob_ref(each_ref_fn_adapter, arg + 7,
+ &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--remotes=")) {
- for_each_glob_ref_in(show_reference, arg + 10,
- "refs/remotes/", NULL);
+ for_each_glob_ref_in(each_ref_fn_adapter, arg + 10,
+ "refs/remotes/", &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--remotes")) {
- for_each_remote_ref(show_reference, NULL);
+ for_each_remote_ref(each_ref_fn_adapter, &wrapped_show_reference);
clear_ref_exclusion(&ref_excludes);
continue;
}