Skip to content

Commit

Permalink
t8001, t8002: fix "blame -L :literal" test on NetBSD
Browse files Browse the repository at this point in the history
Sub-test 42 of t8001 and t8002 ("blame -L :literal") fails on NetBSD
with the following verbose output:

	git annotate  -L:main hello.c
	Author F (expected 4, attributed 3) bad
	Author G (expected 1, attributed 1) good

This is not caused by different behaviour of git blame or annotate on
that platform, but by different test input, in turn caused by a sed
command that forgets to add a newline on NetBSD.  Here's the diff of the
commit that adds "goodbye" to hello.c, for Linux:

	@@ -1,4 +1,5 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	+		puts("goodbye");
	 }

We see that it adds an extra TAB, but that's not a problem.  Here's the
same on NetBSD:

	@@ -1,4 +1,4 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	-}
	+		puts("goodbye");}

It also adds an extra TAB, but it is missing the newline character
after the semicolon.

The following patch gets rid of the extra TAB at the beginning, but
more importantly adds the missing newline at the end in a (hopefully)
portable way, mentioned in http://sed.sourceforge.net/sedfaq4.html.
The diff becomes this, on both Linux and NetBSD:

	@@ -1,4 +1,5 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	+	puts("goodbye");
	 }

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Aug 5, 2013
1 parent df83d5c commit 3a4fc21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions t/annotate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ test_expect_success 'setup -L :regex' '
git commit -m "hello" &&
mv hello.c hello.orig &&
sed -e "/}/i\\
Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c &&
sed -e "/}/ {x; s/$/Qputs(\"goodbye\");/; G;}" <hello.orig |
tr Q "\\t" >hello.c &&
GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="G@test.git" \
git commit -a -m "goodbye" &&
Expand Down

0 comments on commit 3a4fc21

Please sign in to comment.