summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-03 21:21:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-07-09 23:42:23 (GMT)
commit957d74062c1f0e92368aeda335e27d2d61f584f6 (patch)
tree7b5c5c54cfe2d06d741ec8fcd103f1a8eeddcb38 /builtin/rev-parse.c
parentc036c4c5e426cc7ee8070038607edf06ef1d661e (diff)
downloadgit-957d74062c1f0e92368aeda335e27d2d61f584f6.zip
git-957d74062c1f0e92368aeda335e27d2d61f584f6.tar.gz
git-957d74062c1f0e92368aeda335e27d2d61f584f6.tar.bz2
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>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 16b98b5..d85b8a6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -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);