git show <tag>: show the tagger
For commit objects, the Author is shown, so do the equivalent for tag objects, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Dec 18, 2007 at 18:01 UTC
56122ed87af181c88e3121795c292689ac574f01
1 file changed
+31
-7
builtin-log.c
+31
-7
@@ -244,7 +244,28 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
244
return cmd_log_walk(&rev);
245
}
246
247
-static int show_object(const unsigned char *sha1, int suppress_header)
247
+static void show_tagger(char *buf, int len, struct rev_info *rev)
248
+{
249
+ char *email_end, *p;
250
+ unsigned long date;
251
+ int tz;
252
+
253
+ email_end = memchr(buf, '>', len);
254
+ if (!email_end)
255
+ return;
256
+ p = ++email_end;
257
+ while (isspace(*p))
258
+ p++;
259
+ date = strtoul(p, &p, 10);
260
+ while (isspace(*p))
261
+ p++;
262
+ tz = (int)strtol(p, NULL, 10);
263
+ printf("Tagger: %.*s\nDate: %s\n", (int)(email_end - buf), buf,
264
+ show_date(date, tz, rev->date_mode));
265
+}
266
+
267
+static int show_object(const unsigned char *sha1, int show_tag_object,
268
+ struct rev_info *rev)
269
{
270
unsigned long size;
271
enum object_type type;
@@ -254,11 +275,14 @@ static int show_object(const unsigned char *sha1, int suppress_header)
275
if (!buf)
276
return error("Could not read object %s", sha1_to_hex(sha1));
277
257
- if (suppress_header)
258
- while (offset < size && buf[offset++] != '\n') {
259
- int new_offset = offset;
278
+ if (show_tag_object)
279
+ while (offset < size && buf[offset] != '\n') {
280
+ int new_offset = offset + 1;
281
while (new_offset < size && buf[new_offset++] != '\n')
282
; /* do nothing */
283
+ if (!prefixcmp(buf + offset, "tagger "))
284
+ show_tagger(buf + offset + 7,
285
+ new_offset - offset - 7, rev);
286
offset = new_offset;
287
}
288
@@ -299,16 +323,16 @@ int cmd_show(int argc, const char **argv, const char *prefix)
323
const char *name = objects[i].name;
324
switch (o->type) {
325
case OBJ_BLOB:
302
- ret = show_object(o->sha1, 0);
326
+ ret = show_object(o->sha1, 0, NULL);
327
break;
328
case OBJ_TAG: {
329
struct tag *t = (struct tag *)o;
330
307
- printf("%stag %s%s\n\n",
331
+ printf("%stag %s%s\n",
332
diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
333
t->tag,
334
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
311
- ret = show_object(o->sha1, 1);
335
+ ret = show_object(o->sha1, 1, &rev);
336
objects[i].item = (struct object *)t->tagged;
337
i--;
338
break;