From: Junio C Hamano <hidden> Date: 2016-06-15 23:03:55
Jeff King [off-list ref] writes:
So I think _if_ using "diff" attributes is enough for this purpose, then
there is no code to be written. But if somebody wants to draw a
distinction between the uses (I want to diff "foo" files, but never see
them in grep) then we could introduce a "grep" attribute (with the
fallback being the value of the "diff" attribute for that path).
That is all true.
If we were to have a new 'grep' attribute that can be used to
express 'It is OK to diff two versions of this path, but hits by
grep in this path is useless' (and verse versa), the built-in macro
attribute 'binary' should also be updated with it. A path being
'binary' currently means '-diff -merge -text' but it should also
mean '-grep' in the new world, if we were to go in that direction.
Thanks.
From: Jeff King <hidden> Date: 2016-06-15 23:03:55
On Wed, Feb 25, 2015 at 11:01:22AM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
So I think _if_ using "diff" attributes is enough for this purpose, then
there is no code to be written. But if somebody wants to draw a
distinction between the uses (I want to diff "foo" files, but never see
them in grep) then we could introduce a "grep" attribute (with the
fallback being the value of the "diff" attribute for that path).
That is all true.
If we were to have a new 'grep' attribute that can be used to
express 'It is OK to diff two versions of this path, but hits by
grep in this path is useless' (and verse versa), the built-in macro
attribute 'binary' should also be updated with it. A path being
'binary' currently means '-diff -merge -text' but it should also
mean '-grep' in the new world, if we were to go in that direction.
I think it would do so automatically. There is no "grep" attribute
given, so we fall back to the "-diff" attribute. But I do not mind
modifying the macro to be more explicit.
Note also that I am not volunteering to work on this, nor am I convinced
it's actually worth pursuing. I've yet to see a useful case where you
would want text diffs but not greps (or vice versa), and if we can avoid
cluttering the attribute space, we should. I was mostly pointing it out
that it is not logically inconsistent to want such a thing. :)
If somebody does look into it, I suspect the place to start is modifying
userdiff_find_by_path to optionally prefer "grep" to "diff".
-Peff
From: Michael J Gruber <hidden> Date: 2016-06-15 23:03:55
Jeff King venit, vidit, dixit 25.02.2015 20:11:
On Wed, Feb 25, 2015 at 11:01:22AM -0800, Junio C Hamano wrote:
quoted
Jeff King [off-list ref] writes:
quoted
So I think _if_ using "diff" attributes is enough for this purpose, then
there is no code to be written. But if somebody wants to draw a
distinction between the uses (I want to diff "foo" files, but never see
them in grep) then we could introduce a "grep" attribute (with the
fallback being the value of the "diff" attribute for that path).
That is all true.
If we were to have a new 'grep' attribute that can be used to
express 'It is OK to diff two versions of this path, but hits by
grep in this path is useless' (and verse versa), the built-in macro
attribute 'binary' should also be updated with it. A path being
'binary' currently means '-diff -merge -text' but it should also
mean '-grep' in the new world, if we were to go in that direction.
I think it would do so automatically. There is no "grep" attribute
given, so we fall back to the "-diff" attribute. But I do not mind
modifying the macro to be more explicit.
Note also that I am not volunteering to work on this, nor am I convinced
it's actually worth pursuing. I've yet to see a useful case where you
would want text diffs but not greps (or vice versa), and if we can avoid
cluttering the attribute space, we should. I was mostly pointing it out
that it is not logically inconsistent to want such a thing. :)
If somebody does look into it, I suspect the place to start is modifying
userdiff_find_by_path to optionally prefer "grep" to "diff".
-Peff
So, as a summary of the discussion, it seems it's time to switch the
default to --textconv for git grep?
Michael
On Thu, Feb 26, 2015 at 6:16 PM, Michael J Gruber
[off-list ref] wrote:
So, as a summary of the discussion, it seems it's time to switch the
default to --textconv for git grep?
Either that or make it clearer in git-grep.txt about this diff
attribute. It takes me some time to make the connection after reading
both git-grep.txt and gitattributes.txt
--
Duy
On Wed, Feb 25, 2015 at 02:11:08PM -0500, Jeff King wrote:
On Wed, Feb 25, 2015 at 11:01:22AM -0800, Junio C Hamano wrote:
quoted
Jeff King [off-list ref] writes:
quoted
So I think _if_ using "diff" attributes is enough for this purpose, then
there is no code to be written. But if somebody wants to draw a
distinction between the uses (I want to diff "foo" files, but never see
them in grep) then we could introduce a "grep" attribute (with the
fallback being the value of the "diff" attribute for that path).
That is all true.
If we were to have a new 'grep' attribute that can be used to
express 'It is OK to diff two versions of this path, but hits by
grep in this path is useless' (and verse versa), the built-in macro
attribute 'binary' should also be updated with it. A path being
'binary' currently means '-diff -merge -text' but it should also
mean '-grep' in the new world, if we were to go in that direction.
I think it would do so automatically. There is no "grep" attribute
given, so we fall back to the "-diff" attribute. But I do not mind
modifying the macro to be more explicit.
Note also that I am not volunteering to work on this, nor am I convinced
it's actually worth pursuing. I've yet to see a useful case where you
would want text diffs but not greps (or vice versa), and if we can avoid
cluttering the attribute space, we should. I was mostly pointing it out
that it is not logically inconsistent to want such a thing. :)
There have been cases where I wanted grep to always ignore certain
files, but to still get text diffs for those files. One case is people
insist on using ChangeLog files, and another is people who commit
generated files of one sort or another.
Trev
If somebody does look into it, I suspect the place to start is modifying
userdiff_find_by_path to optionally prefer "grep" to "diff".
-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Junio C Hamano <hidden> Date: 2016-06-15 23:03:56
Trevor Saunders [off-list ref] writes:
There have been cases where I wanted grep to always ignore certain
files, but to still get text diffs for those files. One case is people
insist on using ChangeLog files, and another is people who commit
generated files of one sort or another.
The attributes are to say "the contents to be stored in this file is
of this nature". Something inherent to the type of the contents,
and that is why there is no way to countermand them from the command
line.
The "nature of the content" may be "result of comparing two versions
of them textually will never make sense to humans", or "result of
finding substrings in them will never make sense to humans", which
are what "-diff" and hypothetical "-grep" mean, respectively.
"It is inconvenient that I see hits in ChangeLog files when I look
for string BUG" does not make ChangeLog inherently "result of
finding substrings in it never makes sense to humans"-kind of file
type. Maybe somebody who is playing a role of a coder right now may
not look at existing ChangeLog entries, but when that same person
plays the role of a release manager next day, running grep on older
ChangeLog files may become necessary to find changes related to
recent changes. For these "per-invocation" differences, attributes
to declare permenent/inherent nature of the contents is much less
suited than per-invocation inclusion/exclusion mechanism based on
pathspecs, I would think.
On Sat, Feb 28, 2015 at 07:06:16PM -0800, Junio C Hamano wrote:
Trevor Saunders [off-list ref] writes:
quoted
There have been cases where I wanted grep to always ignore certain
files, but to still get text diffs for those files. One case is people
insist on using ChangeLog files, and another is people who commit
generated files of one sort or another.
The attributes are to say "the contents to be stored in this file is
of this nature". Something inherent to the type of the contents,
and that is why there is no way to countermand them from the command
line.
The "nature of the content" may be "result of comparing two versions
of them textually will never make sense to humans", or "result of
finding substrings in them will never make sense to humans", which
are what "-diff" and hypothetical "-grep" mean, respectively.
"It is inconvenient that I see hits in ChangeLog files when I look
for string BUG" does not make ChangeLog inherently "result of
finding substrings in it never makes sense to humans"-kind of file
type. Maybe somebody who is playing a role of a coder right now may
not look at existing ChangeLog entries, but when that same person
plays the role of a release manager next day, running grep on older
ChangeLog files may become necessary to find changes related to
recent changes. For these "per-invocation" differences, attributes
to declare permenent/inherent nature of the contents is much less
suited than per-invocation inclusion/exclusion mechanism based on
pathspecs, I would think.
I think that makes some amount of sense, however typing stuff like
--exclude=ChangeLog all the time is not terribly easy on the hands.
Would it make sense to instead add a config variable grep.exclude?
Trev