builtin/grep.c: add '--column' option to 'git-grep(1)'
Teach 'git-grep(1)' a new option, '--column', to show the column number of the first match on a non-context line. This makes it possible to teach 'contrib/git-jump/git-jump' how to seek to the first matching position of a grep match in your editor, and allows similar additional scripting capabilities. For example: $ git grep -n --column foo | head -n3 .clang-format:51:14:# myFunction(foo, bar, baz); .clang-format:64:7:# int foo(); .clang-format:75:8:# void foo() Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
89252cd069
commit
a449f27ffa
@ -828,6 +828,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||
GREP_PATTERN_TYPE_PCRE),
|
||||
OPT_GROUP(""),
|
||||
OPT_BOOL('n', "line-number", &opt.linenum, N_("show line numbers")),
|
||||
OPT_BOOL(0, "column", &opt.columnnum, N_("show column number of first match")),
|
||||
OPT_NEGBIT('h', NULL, &opt.pathname, N_("don't show filenames"), 1),
|
||||
OPT_BIT('H', NULL, &opt.pathname, N_("show filenames"), 1),
|
||||
OPT_NEGBIT(0, "full-name", &opt.relative,
|
||||
|
Reference in New Issue
Block a user