git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] t8001/t8002 (blame): add blame -L :funcname tests

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 17, 2013, 21:25 UTC
Message-ID
<1374096332-7891-5-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1374096332-7891-1-git-send-email-sunshine@sunshineco.com>

git-blame inherited "-L :funcname" support when "-L :funcname:file" was implemented for git-log. Add tests.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/annotate-tests.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index b6a7478..0bfee00 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -3,17 +3,19 @@
 
 check_count () {
 	head= &&
+	file='file' &&
 	options= &&
 	while :
 	do
 		case "$1" in
 		-h) head="$2"; shift; shift ;;
+		-f) file="$2"; shift; shift ;;
 		-*) options="$options $1"; shift ;;
 		*) break ;;
 		esac
 	done &&
-	echo "$PROG $options file $head" >&4 &&
-	$PROG $options file $head >actual &&
+	echo "$PROG $options $file $head" >&4 &&
+	$PROG $options $file $head >actual &&
 	perl -e '
 		my %expect = (@ARGV);
 		my %count = map { $_ => 0 } keys %expect;
@@ -231,6 +233,48 @@ test_expect_success 'blame -L ,Y (Y > nlines)' '
 	test_must_fail $PROG -L,12345 file
 '
 
+test_expect_success 'setup -L :regex' '
+	tr Q "\\t" >hello.c <<-\EOF &&
+	int main(int argc, const char *argv[])
+	{
+	Qputs("hello");
+	}
+	EOF
+	git add hello.c &&
+	GIT_AUTHOR_NAME="F" GIT_AUTHOR_EMAIL="F@test.git" \
+	git commit -m "hello" &&
+
+	mv hello.c hello.orig &&
+	sed -e "/}/i\\
+	Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c &&
+	GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="G@test.git" \
+	git commit -a -m "goodbye" &&
+
+	mv hello.c hello.orig &&
+	echo "#include <stdio.h>" >hello.c &&
+	cat hello.orig >>hello.c &&
+	tr Q "\\t" >>hello.c <<-\EOF
+	void mail()
+	{
+	Qputs("mail");
+	}
+	EOF
+	GIT_AUTHOR_NAME="H" GIT_AUTHOR_EMAIL="H@test.git" \
+	git commit -a -m "mail"
+'
+
+test_expect_success 'blame -L :literal' '
+	check_count -f hello.c -L:main F 4 G 1
+'
+
+test_expect_success 'blame -L :regex' '
+	check_count -f hello.c "-L:m[a-z][a-z]l" H 4
+'
+
+test_expect_success 'blame -L :nomatch' '
+	test_must_fail $PROG -L:nomatch hello.c
+'
+
 test_expect_success 'blame -L bogus' '
 	test_must_fail $PROG -L file &&
 	test_must_fail $PROG -L1,+ file &&
-- 
1.8.3.3.1016.g4f0baba
Previous: Eric SunshineNext: Eric Sunshine
Message 5 of 12 in “fix blame -L regression; add tests”
  1. 0/6 fix blame -L regression; add testsEric Sunshine, Jul 17, 2013
  2. 1/6 line-range: fix "blame -L X,-N" regressionEric Sunshine, Jul 17, 2013
  3. 2/6 t8001/t8002 (blame): modernize styleEric Sunshine, Jul 17, 2013
  4. 3/6 t8001/t8002 (blame): add blame -L testsEric Sunshine, Jul 17, 2013
  5. 4/6 t8001/t8002 (blame): add blame -L :funcname testsEric Sunshine, Jul 17, 2013
  6. 5/6 blame-options.txt: place each -L option variation on its own lineEric Sunshine, Jul 17, 2013
  7. Thomas RastJul 18, 2013
  8. Junio C HamanoJul 18, 2013
  9. Thomas RastJul 22, 2013
  10. Junio C HamanoJul 22, 2013
  11. 6/6 blame-options.txt: explain that -L <start> and <end> are optionalEric Sunshine, Jul 17, 2013
  12. Thomas RastJul 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.