Re: git grep: search whole tree by default?

2013-10-24 Thread Junio C Hamano
Jeff King p...@peff.net writes:

 That would also provide people who do not like the change of default an
 escape hatch to keep the current behavior. And I do not think scripted
 use will be inconvenienced; they will already have to use . or :/ to
 be explicit (if they care) since the behavior is changing.

There is a big difference between scripted use will have an escape
hatch and scripted use will not be inconvenienced.  We *know*
scripts will be inconvenienced with or without such a configuration
variable, as they *have* to be updated if they rely on the current
behaviour of git grep that limits its search to the current
directory when fed no pathspec (and if their users want to keep the
current behaviour of such scripts).  Anything short of a warning (or
even erroring out) that is designed to annoy the users during the
transition period will help ease the pain of transition of scripts.

An annoying warning still can only *ease*, but cannot eliminate, the
pain of transition. The scripts need to be updated to adjust to the
new behaviour; there is no getting around to it.

Even if we ignore the helping your colleague at her terminal, cf.

http://thread.gmane.org/gmane.comp.version-control.git/133570/focus=133683

issue for now, adding a new configuration variable from day one
makes the transition of scripts somewhat worse, I am afraid.  Doing
so robs us a way to add such an annoying warning to help people
foresee problems in their existing scripts before the default
changes (the configuration presumably will disable the this command
line will behave differently after the default changes warning).

As I said, I think we can train people without an annoying warning,
as hits outside their current directory will serve as an annoyance
already, and people who set such a configuration in their repository
(or $HOME/.gitconfig), get used to the chosen behaviour too much,
and get surprised when they get to use a vanilla intallation of Git
(either helping colleague or setting up a new work environment) have
only themselves to blame, so it may not be too big a deal.

But I do not think the same reasoning extends to scripted uses X-.


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-24 Thread David Aguilar
On Thu, Oct 24, 2013 at 12:40 PM, Junio C Hamano gits...@pobox.com wrote:
 Jeff King p...@peff.net writes:

 That would also provide people who do not like the change of default an
 escape hatch to keep the current behavior. And I do not think scripted
 use will be inconvenienced; they will already have to use . or :/ to
 be explicit (if they care) since the behavior is changing.

 There is a big difference between scripted use will have an escape
 hatch and scripted use will not be inconvenienced.  We *know*
 scripts will be inconvenienced with or without such a configuration
 variable, as they *have* to be updated if they rely on the current
 behaviour of git grep that limits its search to the current
 directory when fed no pathspec (and if their users want to keep the
 current behaviour of such scripts).  Anything short of a warning (or
 even erroring out) that is designed to annoy the users during the
 transition period will help ease the pain of transition of scripts.

 An annoying warning still can only *ease*, but cannot eliminate, the
 pain of transition. The scripts need to be updated to adjust to the
 new behaviour; there is no getting around to it.

 Even if we ignore the helping your colleague at her terminal, cf.

 http://thread.gmane.org/gmane.comp.version-control.git/133570/focus=133683

 issue for now, adding a new configuration variable from day one
 makes the transition of scripts somewhat worse, I am afraid.  Doing
 so robs us a way to add such an annoying warning to help people
 foresee problems in their existing scripts before the default
 changes (the configuration presumably will disable the this command
 line will behave differently after the default changes warning).

 As I said, I think we can train people without an annoying warning,
 as hits outside their current directory will serve as an annoyance
 already, and people who set such a configuration in their repository
 (or $HOME/.gitconfig), get used to the chosen behaviour too much,
 and get surprised when they get to use a vanilla intallation of Git
 (either helping colleague or setting up a new work environment) have
 only themselves to blame, so it may not be too big a deal.

 But I do not think the same reasoning extends to scripted uses X-.

The set of people that script git grep may in fact be pretty low /
almost non-existent so it may be a non-issue, but here's my one data
point:

For git-cola, this change in behavior would not make any difference.
It already jumps to the top-level during startup so its grep feature
is unaffected.

It'd be good to hear from other script writers but that's my $.02.
-- 
David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-24 Thread Jeff King
On Thu, Oct 24, 2013 at 12:40:44PM -0700, Junio C Hamano wrote:

 Jeff King p...@peff.net writes:
 
  That would also provide people who do not like the change of default an
  escape hatch to keep the current behavior. And I do not think scripted
  use will be inconvenienced; they will already have to use . or :/ to
  be explicit (if they care) since the behavior is changing.
 
 There is a big difference between scripted use will have an escape
 hatch and scripted use will not be inconvenienced.

I think my communication may have been muddled in transit. What I meant
regarding inconvenienced was not any more so than by simply changing
the behavior in the first place, since scripts already will need to
start becoming explicit due to the behavior change.

And for the escape hatch, I did not mean for scripts. I actually meant
for users who do not like the extra typing and complain stupid git, I
always want '.'; you used to do what I want and now you do not.

 Even if we ignore the helping your colleague at her terminal, cf.
 
 http://thread.gmane.org/gmane.comp.version-control.git/133570/focus=133683

FWIW, I have never agreed with that line of reasoning. I was going to
explain why, but I see that I already did in response to the article you
linked. :)

 issue for now, adding a new configuration variable from day one
 makes the transition of scripts somewhat worse, I am afraid.  Doing
 so robs us a way to add such an annoying warning to help people
 foresee problems in their existing scripts before the default
 changes (the configuration presumably will disable the this command
 line will behave differently after the default changes warning).

If you want to have an annoying warning, why not consider the config a
tristate? Do X or do Y, or if unset, do X with an annoying warning
(which will switch to Y in the future). That does not help a user who
sets the variable after seeing the warning the first time, then later
runs a script that silently chooses the wrong behavior.

But neither does a warning that is squelched by advice.*, which the user
will also set soon after seeing it.

The only way to hit those scripts is to yell at the user anytime the
appropriate command-line override is not selected, with no way to turn
it off. That's what we're doing now with git add. I think people find
it a little annoying. But perhaps it is the least of all evils.


Anyway, I have said my piece, and I think we are on the same page with
the tradeoffs (what they are, though we may value them differently).  I
do not care that strongly about the config option these days; as I said,
it was something I would have used in certain workflows, but I do not
foresee myself even setting it these days. So I am willing to forego it
if there are concerns it will make things worse.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-24 Thread Duy Nguyen
On Fri, Oct 25, 2013 at 11:37 AM, Jeff King p...@peff.net wrote:
 On Thu, Oct 24, 2013 at 12:40:44PM -0700, Junio C Hamano wrote:

 Jeff King p...@peff.net writes:

  That would also provide people who do not like the change of default an
  escape hatch to keep the current behavior. And I do not think scripted
  use will be inconvenienced; they will already have to use . or :/ to
  be explicit (if they care) since the behavior is changing.

 There is a big difference between scripted use will have an escape
 hatch and scripted use will not be inconvenienced.

 I think my communication may have been muddled in transit. What I meant
 regarding inconvenienced was not any more so than by simply changing
 the behavior in the first place, since scripts already will need to
 start becoming explicit due to the behavior change.

 And for the escape hatch, I did not mean for scripts. I actually meant
 for users who do not like the extra typing and complain stupid git, I
 always want '.'; you used to do what I want and now you do not.

Such an escape hatch may be better done as an alias than a config key
(an alias is a config key anyway). I know it won't be easy to add '.'
if no pathspecs are given, using shell script. But that's something
we could improve, hopefully. An option is we could just export
PATHSPEC_PREFER_* flags via a command line (like --literal-pathspecs).
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


git grep: search whole tree by default?

2013-10-23 Thread Piotr Krukowiecki
Hi,

it would be nice if grep searched not only in current directory and
subdirectories, but in whole tree.

I know I can use :/ as a pathspec, but since most git commands work
tree, I got used to this and forgot that grep is different.

It's easy to make a mistake and believe that your code does not
contain searched string XXX - because you have searched from a
subdirectory, not from the top level of your working tree. OTOH, if
grep searches whole tree, you'll notice you get results from outside
of CWD and if you don't want that, you will be able to limit the
search to '.'

I think there were discussion about how there are several git commands
which do not search in whole tree by default and that it's going to be
changed. I think add is one of such commands. Is 'grep' left
unchanged?

Last discussion I found is from 2011 March
(http://thread.gmane.org/gmane.comp.version-control.git/168063/focus=168188)
and it says it's not going to be changed :(

-- 
Piotr Krukowiecki
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Matthieu Moy
Piotr Krukowiecki piotr.krukowie...@gmail.com writes:

 I think there were discussion about how there are several git commands
 which do not search in whole tree by default and that it's going to be
 changed. I think add is one of such commands. Is 'grep' left
 unchanged?

In summary: changing is painful. The case of git add was really bad,
since the same command had different behavior depending on the options
given, so it was clearly worth the pain. In the case of git grep, the
current behavior is not _that_ bad, so nobody bothered to do the change.

(by do the change, I mean propose a migration plan, convince people
that it is good, ...)

I'd personally be slightly in favor of changing to tree-wide, but
without strong opinion.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Junio C Hamano
Matthieu Moy matthieu@grenoble-inp.fr writes:

 In summary: changing is painful. The case of git add was really bad,
 since the same command had different behavior depending on the options
 given, so it was clearly worth the pain. In the case of git grep, the
 current behavior is not _that_ bad, so nobody bothered to do the change.

 (by do the change, I mean propose a migration plan, convince people
 that it is good, ...)

 I'd personally be slightly in favor of changing to tree-wide, but
 without strong opinion.

After reading that old thread again, I tend to think that the only
reason to favor git grep to start at the $(cwd) is the backward
compatibility.  While I do expect that many people will be annoyed
when git grep (no pathspecs) that is run in a subdirectory starts
spitting out a large number of hits from places irrelevant for the
current task at hand, hits from outside the $(cwd) is something they
can _notice_ easily and their fingers will quickly learn to add .
without even thinking.

I suspect that it would be too late for 2.0 we want to do sometime
early next year, though.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Jed Brown
Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

How would you manage transition from the current behavior?  Warning
people to explicitly use . or :/ during some interim period sounds
worse than just switching the default behavior.


pgpfQuneqo8Z9.pgp
Description: PGP signature


Re: git grep: search whole tree by default?

2013-10-23 Thread Junio C Hamano
Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

 How would you manage transition from the current behavior?  Warning
 people to explicitly use . or :/ during some interim period sounds
 worse than just switching the default behavior.

How would I?

You're asking that question only because you omitted too much from
the quote ;-)

Matthieu Moy matthieu@grenoble-inp.fr wrote:

 In summary: changing is painful. The case of git add was really bad,
 since the same command had different behavior depending on the options
 given, so it was clearly worth the pain. In the case of git grep, the
 current behavior is not _that_ bad, so nobody bothered to do the change.

 (by do the change, I mean propose a migration plan, convince people
 that it is good, ...)

I agree that it is up to those who really want to switch the
default.


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Jed Brown
Junio C Hamano gits...@pobox.com writes:

 Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

 How would you manage transition from the current behavior?  Warning
 people to explicitly use . or :/ during some interim period sounds
 worse than just switching the default behavior.

 How would I?

 You're asking that question only because you omitted too much from
 the quote ;-)

I meant that if the proposed migration plan were to be just change it
and people will learn (because anything more gradual would actually be
worse for users) then is it really too late for Git-2.0?


pgp3mQcztjeYU.pgp
Description: PGP signature


Re: git grep: search whole tree by default?

2013-10-23 Thread Junio C Hamano
Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:

 Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

 How would you manage transition from the current behavior?  Warning
 people to explicitly use . or :/ during some interim period sounds
 worse than just switching the default behavior.

 How would I?

 You're asking that question only because you omitted too much from
 the quote ;-)

 I meant that if the proposed migration plan were to be just change it
 and people will learn (because anything more gradual would actually be
 worse for users) then is it really too late for Git-2.0?

I do not know it that is even a workable plan, but I need to sleep
on it and then hear opinion from others, but in general, if anybody
needs to ask if it is too late, then it already is.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Matthieu Moy
Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:

 Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

 How would you manage transition from the current behavior?  Warning
 people to explicitly use . or :/ during some interim period sounds
 worse than just switching the default behavior.

 How would I?

 You're asking that question only because you omitted too much from
 the quote ;-)

 I meant that if the proposed migration plan were to be just change it
 and people will learn (because anything more gradual would actually be
 worse for users) then is it really too late for Git-2.0?

That may be an option. In the case of git add -u, it was a bit more
complicated, since a badly used git add somehow looses data (not very
serious, you may only loos the index). So, saying after the fact oh, by
the way, I messed up the index was not a very good transition plan.

In the case of grep, I'm starting to get convinced that it's OK to do
so, because the user can basically re-run grep with the right argument
if needed.

The warning could be de-activable with an advice.* option.

Again, no strong opinion here, but that seems workable to me.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread David Aguilar
On Wed, Oct 23, 2013 at 12:31 PM, Junio C Hamano gits...@pobox.com wrote:
 Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:

 Jed Brown j...@59a2.org writes:

 Junio C Hamano gits...@pobox.com writes:
 I suspect that it would be too late for 2.0 we want to do sometime
 early next year, though.

 How would you manage transition from the current behavior?  Warning
 people to explicitly use . or :/ during some interim period sounds
 worse than just switching the default behavior.

 How would I?

 You're asking that question only because you omitted too much from
 the quote ;-)

 I meant that if the proposed migration plan were to be just change it
 and people will learn (because anything more gradual would actually be
 worse for users) then is it really too late for Git-2.0?

 I do not know it that is even a workable plan, but I need to sleep
 on it and then hear opinion from others, but in general, if anybody
 needs to ask if it is too late, then it already is.

Making grep tree-wide would be very welcome here.

IMO Git-2.0 *feels* like a good time to change the default since
there's relatively little downside to doing so, but early next year
is not very long to wait either; it doesn't seem like there's a strong
reason to rush this in.
-- 
David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git grep: search whole tree by default?

2013-10-23 Thread Jeff King
On Wed, Oct 23, 2013 at 10:43:36PM +0200, Matthieu Moy wrote:

 That may be an option. In the case of git add -u, it was a bit more
 complicated, since a badly used git add somehow looses data (not very
 serious, you may only loos the index). So, saying after the fact oh, by
 the way, I messed up the index was not a very good transition plan.
 
 In the case of grep, I'm starting to get convinced that it's OK to do
 so, because the user can basically re-run grep with the right argument
 if needed.

For the same reason, is it insane to want a config option to switch the
default when no command-line option is given? These days I am mostly
working on reasonably-sized projects, and would generally prefer
full-tree grep. But in a past life, I worked on some large projects
where I would never touch anything outside of a particular subtree, and
I generally wanted a more limited grep (i.e., I would park my cwd in
/repo/subsystem1 rather than /repo and work from there, and hits in
/repo/subsystem2 were just useless noise).

That would also provide people who do not like the change of default an
escape hatch to keep the current behavior. And I do not think scripted
use will be inconvenienced; they will already have to use . or :/ to
be explicit (if they care) since the behavior is changing.

 The warning could be de-activable with an advice.* option.

Such a config option could also be used to shut up the warning. Though
if the behavior change is deemed non-intrusive enough to not merit a
deprecation period, I am not really sure it is worth having a noisy
warning.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html