Skip to content

Commit

Permalink
Merge branch 'maint-1.5.4' into maint
Browse files Browse the repository at this point in the history
* maint-1.5.4:
  rev-parse --symbolic-full-name: don't print '^' if SHA1 is not a ref
  • Loading branch information
Junio C Hamano committed May 23, 2008
2 parents 26b4d00 + e00f379 commit 77599cc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions builtin-rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ static void show(const char *arg)
puts(arg);
}

/* Like show(), but with a negation prefix according to type */
static void show_with_type(int type, const char *arg)
{
if (type != show_type)
putchar('^');
show(arg);
}

/* Output a revision, only if filter allows it */
static void show_rev(int type, const unsigned char *sha1, const char *name)
{
Expand All @@ -104,8 +112,6 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
def = NULL;
revs_count++;

if (type != show_type)
putchar('^');
if (symbolic && name) {
if (symbolic == SHOW_SYMBOLIC_FULL) {
unsigned char discard[20];
Expand All @@ -122,20 +128,20 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
*/
break;
case 1: /* happy */
show(full);
show_with_type(type, full);
break;
default: /* ambiguous */
error("refname '%s' is ambiguous", name);
break;
}
} else {
show(name);
show_with_type(type, name);
}
}
else if (abbrev)
show(find_unique_abbrev(sha1, abbrev));
show_with_type(type, find_unique_abbrev(sha1, abbrev));
else
show(sha1_to_hex(sha1));
show_with_type(type, sha1_to_hex(sha1));
}

/* Output a flag, only if filter allows it. */
Expand Down

0 comments on commit 77599cc

Please sign in to comment.