1
/*
2
- * Pickaxe
2
+ * Blame
3
*
4
* Copyright (c) 2006, Junio C Hamano
5
*/
40
static int blank_boundary;
41
static int incremental;
42
static int xdl_opts = XDF_NEED_MINIMAL;
43
+
44
+static enum date_mode blame_date_mode = DATE_ISO8601;
45
+static size_t blame_date_width;
46
+
47
static struct string_list mailmap;
48
49
#ifndef DEBUG
1511
int show_raw_time)
1512
{
1513
static char time_buf[128];
1510
- time_t t = time;
1511
- int minutes, tz;
1512
- struct tm *tm;
1514
+ const char *time_str;
1515
+ int time_len;
1516
+ int tz;
1517
1518
if (show_raw_time) {
1519
sprintf(time_buf, "%lu %s", time, tz_str);
1516
- return time_buf;
1520
}
1518
-
1519
- tz = atoi(tz_str);
1520
- minutes = tz < 0 ? -tz : tz;
1521
- minutes = (minutes / 100)*60 + (minutes % 100);
1522
- minutes = tz < 0 ? -minutes : minutes;
1523
- t = time + minutes * 60;
1524
- tm = gmtime(&t);
1525
-
1526
- strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
1527
- strcat(time_buf, tz_str);
1521
+ else {
1522
+ tz = atoi(tz_str);
1523
+ time_str = show_date(time, tz, blame_date_mode);
1524
+ time_len = strlen(time_str);
1525
+ memcpy(time_buf, time_str, time_len);
1526
+ memset(time_buf + time_len, ' ', blame_date_width - time_len);
1527
+ }
1528
return time_buf;
1529
}
1530
1975
blank_boundary = git_config_bool(var, value);
1976
return 0;
1977
}
1978
+ if (!strcmp(var, "blame.date")) {
1979
+ if (!value)
1980
+ return config_error_nonbool(var);
1981
+ blame_date_mode = parse_date_format(value);
1982
+ return 0;
1983
+ }
1984
return git_default_config(var, value, cb);
1985
}
1986
2245
2246
git_config(git_blame_config, NULL);
2247
init_revisions(&revs, NULL);
2248
+ revs.date_mode = blame_date_mode;
2249
+
2250
save_commit_buffer = 0;
2251
dashdash_pos = 0;
2252
2271
parse_done:
2272
argc = parse_options_end(&ctx);
2273
2266
- if (cmd_is_annotate)
2274
+ if (cmd_is_annotate) {
2275
output_option |= OUTPUT_ANNOTATE_COMPAT;
2276
+ blame_date_mode = DATE_ISO8601;
2277
+ } else {
2278
+ blame_date_mode = revs.date_mode;
2279
+ }
2280
+
2281
+ /* The maximum width used to show the dates */
2282
+ switch (blame_date_mode) {
2283
+ case DATE_RFC2822:
2284
+ blame_date_width = sizeof("Thu, 19 Oct 2006 16:00:04 -0700");
2285
+ break;
2286
+ case DATE_ISO8601:
2287
+ blame_date_width = sizeof("2006-10-19 16:00:04 -0700");
2288
+ break;
2289
+ case DATE_RAW:
2290
+ blame_date_width = sizeof("1161298804 -0700");
2291
+ break;
2292
+ case DATE_SHORT:
2293
+ blame_date_width = sizeof("2006-10-19");
2294
+ break;
2295
+ case DATE_RELATIVE:
2296
+ /* "normal" is used as the fallback for "relative" */
2297
+ case DATE_LOCAL:
2298
+ case DATE_NORMAL:
2299
+ blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
2300
+ break;
2301
+ }
2302
+ blame_date_width -= 1; /* strip the null */
2303
2304
if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
2305
opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |