Re: [PATCH v5 5/7] builtin/grep.c: add '--column' option to 'git-grep(1)'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Taylor Blau <me@xxxxxxxxxxxx> writes:

> I re-read your note and understand more clearly now what your suggestion
> is. To ensure that we're in agreement, do you mean:
>
>   1. '--column -v' will _never_ give a column, but will never die(),
>       either

No, I don't.

>   2. '--column --[and | or | not]' will never give a column, but will
>       also never die(), either.

No, I don't.

If a file does not have substring "foo", then

	git grep -v -e foo file
	git grep --not -e foo file

would hit all lines, just like

	git grep -e '.*' file

does.

I would expect that all of these

	git grep --column/-o -v -e foo file
	git grep --column/-o --not -e foo file
	git grep --column/-o -e '.*' file

give the same output, which is what we would get if we consider the
hit from "choose lines that lack 'foo'" on a line without 'foo' is
caused by the entire contents on the line.  That is in line with
"choose lines that has anything (including nothing)" aka ".*" would
result in the entire line being reported via -o.  The byte offset of
the first hit on such a line reported by --column is also 1, and
that is a good and real answer to the question "git grep --column/-o"
can give.  

In an earlier message, you sounded like you do not think "we did not
have 'foo' on that line, and that is why we are emitting because we
are operating under -v" lack a definite answer for --column, but I
think you are wrong.  "On the entire line, we didn't find 'foo'
anywhere" is good enough reason for me to make the answer "the
entire line contributed to this hit" a definite one.

Exactly the same applies for "git grep --not -e foo".

When "git grep -e bar [--or] --not -e foo" shows a line because the
line has 'bar' on it, we have --column that points at 'b' of the
first 'bar' on the line.  When it shows a line because the line has
neither 'bar' or 'foo', then "--not -e foo" part would give a
definite "the entire line contributed to this decision that it does
not have 'foo'".





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux