All of lore.kernel.org
 help / color / mirror / Atom feed
* Can `git grep` have `--Author` option?
@ 2016-04-05 23:45 Chen Bin
  2016-04-06  6:05 ` Matthieu Moy
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Bin @ 2016-04-05 23:45 UTC (permalink / raw)
  To: git

This is a feature request.

>From time to time, I want to re-use MY code. So git grep with --Author options is really useful. My current git version is 2.6.3, looks it doesn't have this option.

-- 
Best Regards,
Chen Bin

--
Help me, help you

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Can `git grep` have `--Author` option?
  2016-04-05 23:45 Can `git grep` have `--Author` option? Chen Bin
@ 2016-04-06  6:05 ` Matthieu Moy
  2016-04-06 15:22   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Matthieu Moy @ 2016-04-06  6:05 UTC (permalink / raw)
  To: Chen Bin; +Cc: git

Chen Bin <chenbin.sh@gmail.com> writes:

> This is a feature request.
>
> From time to time, I want to re-use MY code. So git grep with --Author
> options is really useful. My current git version is 2.6.3, looks it
> doesn't have this option.

Git doesn't "know" which line of code is yours. What it can do is walk
through history to find out: this is "git blame", and you can already do
"git blame | grep ...".

A "git grep --author" would need to blame all files before searching
inside them, or grep first and blame each line in the result to filter
out lines from the wrong author. That would be possible, but relatively
hard to implement and painfully slow. Which probably explains why no one
implemented it yet ...

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Can `git grep` have `--Author` option?
  2016-04-06  6:05 ` Matthieu Moy
@ 2016-04-06 15:22   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2016-04-06 15:22 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Chen Bin, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> A "git grep --author" would need to blame all files before searching
> inside them, or grep first and blame each line in the result to filter
> out lines from the wrong author. That would be possible, but relatively
> hard to implement and painfully slow. Which probably explains why no one
> implemented it yet ...

More importntly, it would not be all that useful in practice.  I can
see "git log -p --author=me" might, but people usually go from what
the code does and then figure out who wrote it, e.g. you try to see
if there is already code that does something similar to what you
want to do in the current codebase, and then run blame on the found
block to see what commit brought it in if you want to avoid
borrowing code from questionable parties, not the other way around.

One possible use case would be when you asked to produce a code
sample for interviewing or something, but then "log --author=$me"
may be a more effective way to find one.  It would allow you to
demonstrate not just the quality of code but also your ability to
clearly explain your idea to others.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-06 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05 23:45 Can `git grep` have `--Author` option? Chen Bin
2016-04-06  6:05 ` Matthieu Moy
2016-04-06 15:22   ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.