@matheusbsbs / matheus-bagliano / commits / 093dc5bee6
Fork 0

blame -s: suppress author name and time.

With this "git blame -b -s HEAD~n..HEAD" becomes a nicer way to review the result of recent changes in context. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 12, 2007 at 15:50 UTC 093dc5bee61c47f5b0f3bea04339c9bf8839ca47
2 files changed +18 -6
Documentation/git-blame.txt
+4 -1
@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file
8 SYNOPSIS
9 --------
10 [verse]
11 -'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m]
11 +'git-blame' [-c] [-b] [--root] [-s] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m]
12 [-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
13 [<rev> | --contents <file>] [--] <file>
14
@@ -60,6 +60,9 @@ include::blame-options.txt[]
60 -n, --show-number::
61 Show line number in the original commit (Default: off).
62
63 +-s::
64 + Suppress author name and timestamp from the output.
65 +
66 THE PORCELAIN FORMAT
67 --------------------
68
builtin-blame.c
+14 -5
@@ -18,7 +18,7 @@
18 #include "cache-tree.h"
19
20 static char blame_usage[] =
21 -"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
21 +"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
22 " -c Use the same output mode as git-annotate (Default: off)\n"
23 " -b Show blank SHA-1 for boundary commits (Default: off)\n"
24 " -l Show long commit SHA1 (Default: off)\n"
@@ -26,6 +26,7 @@ static char blame_usage[] =
26 " -t Show raw timestamp (Default: off)\n"
27 " -f, --show-name Show original filename (Default: auto)\n"
28 " -n, --show-number Show original linenumber (Default: off)\n"
29 +" -s Suppress author name and timestamp (Default: off)\n"
30 " -p, --porcelain Show in a format designed for machine consumption\n"
31 " -L n,m Process only line range n,m, counting from 1\n"
32 " -M, -C Find line movements within and across files\n"
@@ -1483,6 +1484,7 @@ static const char *format_time(unsigned long time, const char *tz_str,
1484 #define OUTPUT_SHOW_NAME 020
1485 #define OUTPUT_SHOW_NUMBER 040
1486 #define OUTPUT_SHOW_SCORE 0100
1487 +#define OUTPUT_NO_AUTHOR 0200
1488
1489 static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
1490 {
@@ -1577,10 +1579,15 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
1579 if (opt & OUTPUT_SHOW_NUMBER)
1580 printf(" %*d", max_orig_digits,
1581 ent->s_lno + 1 + cnt);
1580 - printf(" (%-*.*s %10s %*d) ",
1581 - longest_author, longest_author, ci.author,
1582 - format_time(ci.author_time, ci.author_tz,
1583 - show_raw_time),
1582 +
1583 + if (!(opt & OUTPUT_NO_AUTHOR))
1584 + printf(" (%-*.*s %10s",
1585 + longest_author, longest_author,
1586 + ci.author,
1587 + format_time(ci.author_time,
1588 + ci.author_tz,
1589 + show_raw_time));
1590 + printf(" %*d) ",
1591 max_digits, ent->lno + 1 + cnt);
1592 }
1593 do {
@@ -2092,6 +2099,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2099 output_option |= OUTPUT_RAW_TIMESTAMP;
2100 else if (!strcmp("-l", arg))
2101 output_option |= OUTPUT_LONG_OBJECT_NAME;
2102 + else if (!strcmp("-s", arg))
2103 + output_option |= OUTPUT_NO_AUTHOR;
2104 else if (!strcmp("-S", arg) && ++i < argc)
2105 revs_file = argv[i];
2106 else if (!prefixcmp(arg, "-M")) {