rev-parse --disambiguate=<prefix>

The new option allows you to feed an ambiguous prefix and enumerate
all the objects that share it as a prefix of their object names.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2012-07-03 14:21:59 -07:00
parent c036c4c5e4
commit 957d74062c
5 changed files with 78 additions and 9 deletions

View File

@ -195,6 +195,12 @@ static int anti_reference(const char *refname, const unsigned char *sha1, int fl
return 0;
}
static int show_abbrev(const unsigned char *sha1, void *cb_data)
{
show_rev(NORMAL, sha1, NULL);
return 0;
}
static void show_datestring(const char *flag, const char *datestr)
{
static char buffer[100];
@ -589,6 +595,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref(show_reference, NULL);
continue;
}
if (!prefixcmp(arg, "--disambiguate=")) {
for_each_abbrev(arg + 15, show_abbrev, NULL);
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);