22
const char *pattern = NULL;
23
24
struct commit_name {
25
+ struct tag *tag;
26
int prio; /* annotated tag = 2, tag = 1, head = 0 */
27
+ unsigned char sha1[20];
28
char path[FLEX_ARRAY]; /* more */
29
};
30
static const char *prio_names[] = {
33
34
static void add_to_known_names(const char *path,
35
struct commit *commit,
34
- int prio)
36
+ int prio,
37
+ const unsigned char *sha1)
38
{
39
struct commit_name *e = commit->util;
40
if (!e || e->prio < prio) {
41
size_t len = strlen(path)+1;
42
free(e);
43
e = xmalloc(sizeof(struct commit_name) + len);
44
+ e->tag = NULL;
45
e->prio = prio;
46
+ hashcpy(e->sha1, sha1);
47
memcpy(e->path, path, len);
48
commit->util = e;
49
}
94
if (!tags && prio < 2)
95
return 0;
96
}
92
- add_to_known_names(all ? path + 5 : path + 10, commit, prio);
97
+ add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);
98
return 0;
99
}
100
151
return seen_commits;
152
}
153
154
+static void display_name(struct commit_name *n)
155
+{
156
+ if (n->prio == 2 && !n->tag) {
157
+ n->tag = lookup_tag(n->sha1);
158
+ if (!n->tag || !n->tag->tag)
159
+ die("annotated tag %s not available", n->path);
160
+ if (strcmp(n->tag->tag, n->path))
161
+ warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
162
+ }
163
+
164
+ if (n->tag)
165
+ printf("%s", n->tag->tag);
166
+ else
167
+ printf("%s", n->path);
168
+}
169
+
170
static void describe(const char *arg, int last_one)
171
{
172
unsigned char sha1[20];
191
192
n = cmit->util;
193
if (n) {
173
- printf("%s\n", n->path);
194
+ display_name(n);
195
+ printf("\n");
196
return;
197
}
198
274
sha1_to_hex(gave_up_on->object.sha1));
275
}
276
}
255
- if (abbrev == 0)
256
- printf("%s\n", all_matches[0].name->path );
257
- else
258
- printf("%s-%d-g%s\n", all_matches[0].name->path,
259
- all_matches[0].depth,
277
+
278
+ display_name(all_matches[0].name);
279
+ if (abbrev)
280
+ printf("-%d-g%s", all_matches[0].depth,
281
find_unique_abbrev(cmit->object.sha1, abbrev));
282
+ printf("\n");
283
284
if (!last_one)
285
clear_commit_marks(cmit, -1);