git log -S not finding all commits?

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

git log -S not finding all commits?

From: Daniel <hidden>
Date: 2016-06-15 22:47:29

Hi,

I did:

$ git version
git version 1.6.4.4
$ mkdir a && cd a && git init
$ echo "Free data" > a
$ git add a
$ git commit -m1
$ echo "Free data allocated by other function" > a
$ git commit -a -m2
$ PAGER=cat git log -S'Free' --oneline
2f34241 1

I would expect "git log" to show both 1 and 2 commit, but it prints only 1.

Is it the correct behavior?

-- 
Daniel

Re: git log -S not finding all commits?

From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:47:29

On 10/08/2009 10:21 AM, Daniel wrote:
Hi,

I did:

$ git version
git version 1.6.4.4
$ mkdir a&&  cd a&&  git init
$ echo "Free data">  a
$ git add a
$ git commit -m1
$ echo "Free data allocated by other function">  a
$ git commit -a -m2
$ PAGER=cat git log -S'Free' --oneline
2f34241 1

I would expect "git log" to show both 1 and 2 commit, but it prints only 1.

Is it the correct behavior?
Yes, it's the correct behaviour. -S finds only lines where what you search
for was added or deleted. It counts the number of occurrences of what you
specify in each resulting tree and only shows the commits where that number
changed. In your case, searching for "Free data " would have printed both
commits, since you first introduce that entire string and then remove it.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

Re: git log -S not finding all commits?

From: Daniel <hidden>
Date: 2016-06-15 22:47:29

Andreas Ericsson [off-list ref] wrote:
Yes, it's the correct behaviour. -S finds only lines where what you search
for was added or deleted. It counts the number of occurrences of what you
specify in each resulting tree and only shows the commits where that number
changed. In your case, searching for "Free data " would have printed both
commits, since you first introduce that entire string and then remove it.
Thanks. However, your suggestion doesn't work. It prints only commit 2. Maybe
you meant:

$ PAGER=cat git log --pickaxe-regex -S'Free data$' --oneline

but that doesn't solve my problem. I want to find all commits which changed
lines containing "Free data" (the example I posted is simplified).

Seems I have to use "git log -p" and search its output using pager...

-- 
Daniel

Re: git log -S not finding all commits?

From: Nanako Shiraishi <hidden>
Date: 2016-06-15 22:47:29

Quoting Daniel [off-list ref]
$ git version
git version 1.6.4.4
$ mkdir a && cd a && git init
$ echo "Free data" > a
$ git add a
$ git commit -m1
$ echo "Free data allocated by other function" > a
$ git commit -a -m2
$ PAGER=cat git log -S'Free' --oneline
2f34241 1

I would expect "git log" to show both 1 and 2 commit, but it prints only 1.

Is it the correct behavior?
Junio described how various features in git were invented to realize the goal of "Linus's ultimate content tracking" in his blog http://gitster.livejournal.com/35628.html (and he extended on the article in a chapter in his book that was published in Japan last month).

The "pickaxe" search is one of such components. It is meant to be given the block of lines you are interested in the newer version and used to find the commit that changes anything in the given block of lines. For details, see his blog article (item no. 3) at the above URL (and other items as well, if you are interested in learning the history of other notable features).

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help