describe: fix --long output
An error while hand-merging broke the new "--long" option. This should fix it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 3, 2008 at 13:08 UTC
870cf7d69872ebc925989b400fb4e7031870db5f
1 file changed
+11
-5
builtin-describe.c
+11
-5
@@ -166,9 +166,11 @@ static void display_name(struct commit_name *n)
166
printf("%s", n->tag->tag);
167
else
168
printf("%s", n->path);
169
- if (longformat)
170
- printf("-0-g%s",
171
- find_unique_abbrev(n->tag->tagged->sha1, abbrev));
169
+}
170
+
171
+static void show_suffix(int depth, const unsigned char *sha1)
172
+{
173
+ printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev));
174
}
175
176
static void describe(const char *arg, int last_one)
@@ -195,7 +197,12 @@ static void describe(const char *arg, int last_one)
197
198
n = cmit->util;
199
if (n) {
200
+ /*
201
+ * Exact match to an existing ref.
202
+ */
203
display_name(n);
204
+ if (longformat)
205
+ show_suffix(0, n->tag->tagged->sha1);
206
printf("\n");
207
return;
208
}
@@ -281,8 +288,7 @@ static void describe(const char *arg, int last_one)
288
289
display_name(all_matches[0].name);
290
if (abbrev)
284
- printf("-%d-g%s", all_matches[0].depth,
285
- find_unique_abbrev(cmit->object.sha1, abbrev));
291
+ show_suffix(all_matches[0].depth, cmit->object.sha1);
292
printf("\n");
293
294
if (!last_one)