git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Expected behaviour of 'git log -S' when searching in a merged/deleted file?
@ 2010-12-22 13:37 Jonathan del Strother
  2010-12-22 18:17 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan del Strother @ 2010-12-22 13:37 UTC (permalink / raw)
  To: Git Mailing List

Hi,

I was trying to find a particular string in my project this morning.
'git grep mystring' suggested that the string didn't exist in my repo,
but 'git log -Smystring' turned up a single commit that had added it.
It took me a long time to figure out that in the past, a branch had
added that string to foo.c, but a second branch deleted foo.c, and the
two branches were later merged (deleting foo.c and ignoring mystring).
 I was surprised that 'git log -S' didn't show the merge commit as the
point at which the string had been removed.

I've attached a testcase which I would expect to pass (perhaps
naively), but doesn't.  Is this a git bug, or do I misunderstand git
log -S?

--


#!/bin/sh

test_description='git log'

. ./test-lib.sh

test_expect_success setup '
	echo haystack\\nhaystack\\nhaystack\\nhaystack\\n > haystack &&
	git add haystack &&
	test_tick &&
	git commit -m initial &&

	git checkout -b branchA &&
	echo needle >haystack &&
	git add haystack &&
	test_tick &&
	git commit -m "adding needle" &&

	git checkout -b branchB HEAD~1 &&
	git rm haystack &&
	test_tick &&
	git commit -m "removing haystack" &&

	git merge branchA || git rm haystack &&
	test_tick &&
	git commit -m "merging: haystack and needle removed"
'

printf "merging: haystack and needle removed\nadding needle" > expect
test_expect_success 'log -S in a merge-deleted file' '

	git log -Sneedle --pretty="format:%s" > actual &&
	test_cmp expect actual
'

test_done

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

end of thread, other threads:[~2010-12-23 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-22 13:37 Expected behaviour of 'git log -S' when searching in a merged/deleted file? Jonathan del Strother
2010-12-22 18:17 ` Junio C Hamano
2010-12-23  9:47   ` Jonathan del Strother
2010-12-23 16:03     ` Junio C Hamano
2010-12-23 17:27       ` Jonathan del Strother

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).