git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD
@ 2013-08-05 15:21 René Scharfe
  2013-08-05 15:33 ` Eric Sunshine
  2013-08-05 17:44 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: René Scharfe @ 2013-08-05 15:21 UTC (permalink / raw
  To: Eric Sunshine; +Cc: git discussion list, Junio C Hamano

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>
---
This regression was introduced by 5a9830cb ("t8001/t8002 (blame):
add blame -L :funcname tests").

 t/annotate-tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 0bfee00..d4e7f47 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -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" &&
 
-- 
1.8.1.5

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

* Re: [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD
  2013-08-05 15:21 [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD René Scharfe
@ 2013-08-05 15:33 ` Eric Sunshine
  2013-08-05 17:44 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2013-08-05 15:33 UTC (permalink / raw
  To: René Scharfe; +Cc: git discussion list, Junio C Hamano

On Mon, Aug 5, 2013 at 11:21 AM, René Scharfe <l.s.r@web.de> wrote:
> 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,

Curious. On Mac OS X, there is only a single 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.

Tested on Mac OS X. Works correctly.

> 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>
> ---
> This regression was introduced by 5a9830cb ("t8001/t8002 (blame):
> add blame -L :funcname tests").
>
>  t/annotate-tests.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
> index 0bfee00..d4e7f47 100644
> --- a/t/annotate-tests.sh
> +++ b/t/annotate-tests.sh
> @@ -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 &&

Thanks.

Acked-by: Eric Sunshine <sunshine@sunshineco.com>

>         GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="G@test.git" \
>         git commit -a -m "goodbye" &&

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

* Re: [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD
  2013-08-05 15:21 [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD René Scharfe
  2013-08-05 15:33 ` Eric Sunshine
@ 2013-08-05 17:44 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-08-05 17:44 UTC (permalink / raw
  To: René Scharfe; +Cc: Eric Sunshine, git discussion list

Thanks.

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

end of thread, other threads:[~2013-08-05 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-05 15:21 [PATCH] t8001, t8002: fix "blame -L :literal" test on NetBSD René Scharfe
2013-08-05 15:33 ` Eric Sunshine
2013-08-05 17:44 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).