git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to find a commit that introduces (not removes) a string?
@ 2011-11-03  9:50 Sebastian Schuberth
  2011-11-03 15:56 ` Neal Kreitzinger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Schuberth @ 2011-11-03  9:50 UTC (permalink / raw)
  To: git

Hi all,

I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?

Thanks!

PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.

[1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string

-- 
Sebastian Schuberth

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

* Re: How to find a commit that introduces (not removes) a string?
  2011-11-03  9:50 How to find a commit that introduces (not removes) a string? Sebastian Schuberth
@ 2011-11-03 15:56 ` Neal Kreitzinger
  2011-11-03 16:13 ` Vijay Lakshminarayanan
  2011-11-04 10:59 ` Sebastian Schuberth
  2 siblings, 0 replies; 4+ messages in thread
From: Neal Kreitzinger @ 2011-11-03 15:56 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: git

On 11/3/2011 4:50 AM, Sebastian Schuberth wrote:
> Hi all,
>
> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?
>
> Thanks!
>
> PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.
>
> [1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string
>
If you are using linux, here is git diff command I use to find leftover 
debug statements.  I imagine the -S option will work the same in git 
log.  I pipe the results into grep to filter the results to show only 
the additions. (I'm using git 1.7.1)

$ git diff --unified=0 -S"DEBUG" <commit> <commit> -- <path> | grep -e 
"diff --" -e "+" | grep -v -e "@@" -e "+++"

maybe you will find this helpful.

v/r,
neal

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

* Re: How to find a commit that introduces (not removes) a string?
  2011-11-03  9:50 How to find a commit that introduces (not removes) a string? Sebastian Schuberth
  2011-11-03 15:56 ` Neal Kreitzinger
@ 2011-11-03 16:13 ` Vijay Lakshminarayanan
  2011-11-04 10:59 ` Sebastian Schuberth
  2 siblings, 0 replies; 4+ messages in thread
From: Vijay Lakshminarayanan @ 2011-11-03 16:13 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: git

Sebastian Schuberth <sschuberth@gmail.com> writes:

> Hi all,
>
> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?

This appears to work:

$ for ref in `git log -SWORD --pretty=format:"%h"` ; do 
    git log -1 -p $ref | grep WORD | grep -E '^[+]' > /dev/null ; 
    if [ $? -eq 0 ]; then 
        echo $ref; 
    fi ;
  done

substitute WORD for what you're looking for.  Note that it is repeated
twice.

> Thanks!
>
> PS: I also read [1], but although the author claims to be interested in introduced strings only, he seems to be satisfied with -G, which slightly puzzles me.
>
> [1] http://stackoverflow.com/questions/5816134/git-finding-a-commit-that-introduced-a-string

-- 
Cheers
~vijay

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

* Re: How to find a commit that introduces (not removes) a string?
  2011-11-03  9:50 How to find a commit that introduces (not removes) a string? Sebastian Schuberth
  2011-11-03 15:56 ` Neal Kreitzinger
  2011-11-03 16:13 ` Vijay Lakshminarayanan
@ 2011-11-04 10:59 ` Sebastian Schuberth
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Schuberth @ 2011-11-04 10:59 UTC (permalink / raw)
  Cc: git, nkreitzinger, laksvij

On 03.11.2011 10:50, Sebastian Schuberth wrote:

> I know about git log's -S / -G, but I'm unable to make these search through *introduced* strings only. Is there a way to do so?

Thanks for your suggestions. However, I ended up simply doing

$ git diff --no-color FROM..TO | grep ^+[^+] | grep WORD

which works well for my case.

-- 
Sebastian Schuberth

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

end of thread, other threads:[~2011-11-04 11:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03  9:50 How to find a commit that introduces (not removes) a string? Sebastian Schuberth
2011-11-03 15:56 ` Neal Kreitzinger
2011-11-03 16:13 ` Vijay Lakshminarayanan
2011-11-04 10:59 ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).