{"thread":{"id":"41940","subject":"Can `git grep` have `--Author` option?","startedAt":"2016-04-05T23:45:54Z","lastAt":"2016-04-06T15:22:16Z","messageCount":3,"participants":["Chen Bin","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"282741","messageId":"8737qztya5.fsf@gmail.com","threadId":"41940","inReplyTo":null,"subject":"Can `git grep` have `--Author` option?","fromName":"Chen Bin","fromEmail":"chenbin.sh@gmail.com","sentAt":"2016-04-05T23:45:54Z","receivedAt":"2016-04-05T23:45:54Z","isPatch":false,"sender":{"key":"chenbin.sh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/184553?v=4"},"body":"This is a feature request.\n\n>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.\n\n-- \nBest Regards,\nChen Bin\n\n--\nHelp me, help you\n"},{"id":"282745","messageId":"vpqshyzw9u3.fsf@anie.imag.fr","threadId":"41940","inReplyTo":"8737qztya5.fsf@gmail.com","subject":"Re: Can `git grep` have `--Author` option?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-04-06T06:05:40Z","receivedAt":"2016-04-06T06:05:40Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Chen Bin <chenbin.sh@gmail.com> writes:\n\n> This is a feature request.\n>\n> From time to time, I want to re-use MY code. So git grep with --Author\n> options is really useful. My current git version is 2.6.3, looks it\n> doesn't have this option.\n\nGit doesn't \"know\" which line of code is yours. What it can do is walk\nthrough history to find out: this is \"git blame\", and you can already do\n\"git blame | grep ...\".\n\nA \"git grep --author\" would need to blame all files before searching\ninside them, or grep first and blame each line in the result to filter\nout lines from the wrong author. That would be possible, but relatively\nhard to implement and painfully slow. Which probably explains why no one\nimplemented it yet ...\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"282767","messageId":"xmqqegaizrrr.fsf@gitster.mtv.corp.google.com","threadId":"41940","inReplyTo":"vpqshyzw9u3.fsf@anie.imag.fr","subject":"Re: Can `git grep` have `--Author` option?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-06T15:22:16Z","receivedAt":"2016-04-06T15:22:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> A \"git grep --author\" would need to blame all files before searching\n> inside them, or grep first and blame each line in the result to filter\n> out lines from the wrong author. That would be possible, but relatively\n> hard to implement and painfully slow. Which probably explains why no one\n> implemented it yet ...\n\nMore importntly, it would not be all that useful in practice.  I can\nsee \"git log -p --author=me\" might, but people usually go from what\nthe code does and then figure out who wrote it, e.g. you try to see\nif there is already code that does something similar to what you\nwant to do in the current codebase, and then run blame on the found\nblock to see what commit brought it in if you want to avoid\nborrowing code from questionable parties, not the other way around.\n\nOne possible use case would be when you asked to produce a code\nsample for interviewing or something, but then \"log --author=$me\"\nmay be a more effective way to find one.  It would allow you to\ndemonstrate not just the quality of code but also your ability to\nclearly explain your idea to others.\n"}]}