Anonymous avatar Anonymous committed e00f379

rev-parse --symbolic-full-name: don't print '^' if SHA1 is not a ref

The intention of --symbolic-full-name is to not print anything if a
revision is not an exact ref. But this command:

$ git-rev-parse --symbolic-full-name --not master~1

still emitted a sole '^' to stdout (provided that there's no other ref at
master~1). This fixes it.

Signed-off-by: Johannes Sixt <>;
Signed-off-by: Junio C Hamano <>;

Comments (0)

Files changed (1)


+/* 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)
 	def = NULL;
-	if (type != show_type)
-		putchar('^');
 	if (symbolic && name) {
 		if (symbolic == SHOW_SYMBOLIC_FULL) {
 			unsigned char discard[20];
 			case 1: /* happy */
-				show(full);
+				show_with_type(type, full);
 			default: /* ambiguous */
 				error("refname '%s' is ambiguous", name);
 		} 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));
-		show(sha1_to_hex(sha1));
+		show_with_type(type, sha1_to_hex(sha1));
 /* Output a flag, only if filter allows it. */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.