path: root/builtin/rev-parse.c
diff options
authorJunio C Hamano <>2012-07-22 19:55:07 (GMT)
committerJunio C Hamano <>2012-07-22 19:55:07 (GMT)
commit0958a24d7360759902f802744c0839c8029659d7 (patch)
treef22a0b0f2cb4dc8e7c4e0b5a053d0bac01c445bf /builtin/rev-parse.c
parent9a0231b395cb9720365b7066312eeaa86e37ed31 (diff)
parent31ffd0c0c1255cb7e9ba76192a70ae294faf95bf (diff)
Merge branch 'jc/sha1-name-more'
Teaches the object name parser things like a "git describe" output is always a commit object, "A" in "git log A" must be a committish, and "A" and "B" in "git log A...B" both must be committish, etc., to prolong the lifetime of abbreviated object names. * jc/sha1-name-more: (27 commits) t1512: match the "other" object names t1512: ignore whitespaces in wc -l output rev-parse --disambiguate=<prefix> rev-parse: A and B in "rev-parse A..B" refer to committish reset: the command takes committish commit-tree: the command wants a tree and commits apply: --build-fake-ancestor expects blobs sha1_name.c: add support for disambiguating other types revision.c: the "log" family, except for "show", takes committish revision.c: allow handle_revision_arg() to take other flags sha1_name.c: introduce get_sha1_committish() sha1_name.c: teach lookup context to get_sha1_with_context() sha1_name.c: many short names can only be committish sha1_name.c: get_sha1_1() takes lookup flags sha1_name.c: get_describe_name() by definition groks only commits sha1_name.c: teach get_short_sha1() a commit-only option sha1_name.c: allow get_short_sha1() to take other flags get_sha1(): fix error status regression sha1_name.c: restructure disambiguation of short names sha1_name.c: correct misnamed "canonical" and "res" ...
Diffstat (limited to 'builtin/rev-parse.c')
1 files changed, 12 insertions, 2 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 13495b8..32788a9 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];
@@ -238,7 +244,7 @@ static int try_difference(const char *arg)
next = "HEAD";
if (dotdot == arg)
this = "HEAD";
- if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
+ if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
show_rev(NORMAL, end, next);
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
if (symmetric) {
@@ -278,7 +284,7 @@ static int try_parent_shorthands(const char *arg)
return 0;
*dotdot = 0;
- if (get_sha1(arg, sha1))
+ if (get_sha1_committish(arg, sha1))
return 0;
if (!parents_only)
@@ -589,6 +595,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for_each_ref(show_reference, NULL);
+ 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);