Skip to content

Commit 90ac368

Browse files
committed
Merge branch 'jc/blame' (early part)
* 'jc/blame' (early part): git-blame -w: ignore whitespace git-blame: do not indent with spaces.
2 parents 6815e56 + b82871b commit 90ac368

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Documentation/git-blame.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git-blame' [-c] [-b] [--root] [-s] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m]
11+
'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
1212
[-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
1313
[<rev> | --contents <file>] [--] <file>
1414

@@ -63,6 +63,11 @@ include::blame-options.txt[]
6363
-s::
6464
Suppress author name and timestamp from the output.
6565

66+
-w::
67+
Ignore whitespace when comparing parent's version and
68+
child's to find where the lines came from.
69+
70+
6671
THE PORCELAIN FORMAT
6772
--------------------
6873

builtin-blame.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "mailmap.h"
2121

2222
static char blame_usage[] =
23-
"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"
23+
"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
2424
" -c Use the same output mode as git-annotate (Default: off)\n"
2525
" -b Show blank SHA-1 for boundary commits (Default: off)\n"
2626
" -l Show long commit SHA1 (Default: off)\n"
@@ -30,6 +30,7 @@ static char blame_usage[] =
3030
" -n, --show-number Show original linenumber (Default: off)\n"
3131
" -s Suppress author name and timestamp (Default: off)\n"
3232
" -p, --porcelain Show in a format designed for machine consumption\n"
33+
" -w Ignore whitespace differences\n"
3334
" -L n,m Process only line range n,m, counting from 1\n"
3435
" -M, -C Find line movements within and across files\n"
3536
" --incremental Show blame entries as we find them, incrementally\n"
@@ -45,6 +46,7 @@ static int show_root;
4546
static int blank_boundary;
4647
static int incremental;
4748
static int cmd_is_annotate;
49+
static int xdl_opts = XDF_NEED_MINIMAL;
4850
static struct path_list mailmap;
4951

5052
#ifndef DEBUG
@@ -515,7 +517,7 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
515517
xdemitconf_t xecfg;
516518
xdemitcb_t ecb;
517519

518-
xpp.flags = XDF_NEED_MINIMAL;
520+
xpp.flags = xdl_opts;
519521
xecfg.ctxlen = context;
520522
xecfg.flags = 0;
521523
ecb.outf = xdiff_outf;
@@ -1744,11 +1746,11 @@ static int read_ancestry(const char *graft_file)
17441746
*/
17451747
static int lineno_width(int lines)
17461748
{
1747-
int i, width;
1749+
int i, width;
17481750

1749-
for (width = 1, i = 10; i <= lines + 1; width++)
1750-
i *= 10;
1751-
return width;
1751+
for (width = 1, i = 10; i <= lines + 1; width++)
1752+
i *= 10;
1753+
return width;
17521754
}
17531755

17541756
/*
@@ -2159,6 +2161,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
21592161
output_option |= OUTPUT_LONG_OBJECT_NAME;
21602162
else if (!strcmp("-s", arg))
21612163
output_option |= OUTPUT_NO_AUTHOR;
2164+
else if (!strcmp("-w", arg))
2165+
xdl_opts |= XDF_IGNORE_WHITESPACE;
21622166
else if (!strcmp("-S", arg) && ++i < argc)
21632167
revs_file = argv[i];
21642168
else if (!prefixcmp(arg, "-M")) {

0 commit comments

Comments
 (0)