aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 44ff1b8342..9032cc6327 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -217,19 +217,17 @@ static int show_default(void)
return 0;
}
-static int show_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid,
- int flag UNUSED, void *cb_data UNUSED)
+static int show_reference(const struct reference *ref, void *cb_data UNUSED)
{
- if (ref_excluded(&ref_excludes, refname))
+ if (ref_excluded(&ref_excludes, ref->name))
return 0;
- show_rev(NORMAL, oid, refname);
+ show_rev(NORMAL, ref->oid, ref->name);
return 0;
}
-static int anti_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid,
- int flag UNUSED, void *cb_data UNUSED)
+static int anti_reference(const struct reference *ref, void *cb_data UNUSED)
{
- show_rev(REVERSED, oid, refname);
+ show_rev(REVERSED, ref->oid, ref->name);
return 0;
}
@@ -708,7 +706,6 @@ int cmd_rev_parse(int argc,
struct object_id oid;
unsigned int flags = 0;
const char *name = NULL;
- struct object_context unused;
struct strbuf buf = STRBUF_INIT;
int seen_end_of_options = 0;
enum format_type format = FORMAT_DEFAULT;
@@ -1108,11 +1105,20 @@ int cmd_rev_parse(int argc,
const char *val = arg ? arg : "storage";
if (strcmp(val, "storage") &&
+ strcmp(val, "compat") &&
strcmp(val, "input") &&
strcmp(val, "output"))
die(_("unknown mode for --show-object-format: %s"),
arg);
- puts(the_hash_algo->name);
+
+ if (!strcmp(val, "compat")) {
+ if (the_repository->compat_hash_algo)
+ puts(the_repository->compat_hash_algo->name);
+ else
+ putchar('\n');
+ } else {
+ puts(the_hash_algo->name);
+ }
continue;
}
if (!strcmp(arg, "--show-ref-format")) {
@@ -1141,9 +1147,8 @@ int cmd_rev_parse(int argc,
name++;
type = REVERSED;
}
- if (!get_oid_with_context(the_repository, name,
- flags, &oid, &unused)) {
- object_context_release(&unused);
+ if (!repo_get_oid_with_flags(the_repository, name, &oid,
+ flags)) {
if (output_algo)
repo_oid_to_algop(the_repository, &oid,
output_algo, &oid);
@@ -1153,7 +1158,6 @@ int cmd_rev_parse(int argc,
show_rev(type, &oid, name);
continue;
}
- object_context_release(&unused);
if (verify)
die_no_single_rev(quiet);
if (has_dashdash)