threads / patch / 4564

patchMake t8001-annotate and t8002-blame more portable

Subject: [PATCH] Make t8001-annotate and t8002-blame more portable

## tl;dr

6 messages between Jun 18, 2006 and Jun 19, 2006. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Dennis Stosberg· Jun 18, 2006, 20:33 UTC · lore

These two tests assume that "sed" will not modify the final line of a stream if it does not end with a newline character. The assumption is not true at least for FreeBSD and Solaris 9. FreeBSD's "sed" appends a newline character; "sed" in Solaris 9 even removes the incomplete final line. This patch makes the test use perl instead.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---
 t/annotate-tests.sh |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
Show changes to t/annotate-tests.sh +1 −3
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 114938c..71d0f30 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -111,9 +111,7 @@ test_expect_success \
 
 test_expect_success \
     'some edit' \
-    'mv file file1 &&
-     sed -e 1d -e "5s/3A/99/" file1 >file &&
-     rm -f file1 &&
+    'perl -pi -e "s/^1A.*\n$//; s/^3A/99/" file &&
     GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
 
 test_expect_success \
-- 
1.4.0
Junio C Hamano· Jun 18, 2006, 20:58 UTC · re: Dennis Stosberg · lore

Re: [PATCH] Make t8001-annotate and t8002-blame more portable

Dennis Stosberg <dennis@stosberg.net> writes:
Show 5 quoted lines
> These two tests assume that "sed" will not modify the final line of a
> stream if it does not end with a newline character.  The assumption is
> not true at least for FreeBSD and Solaris 9.  FreeBSD's "sed" appends
> a newline character; "sed" in Solaris 9 even removes the incomplete
> final line.
Gaaah.
Show 5 quoted lines
> -    'mv file file1 &&
> -     sed -e 1d -e "5s/3A/99/" file1 >file &&
> -     rm -f file1 &&
> +    'perl -pi -e "s/^1A.*\n$//; s/^3A/99/" file &&
>      GIT_AUTHOR_NAME="D" git commit -a -m "edit"'

The first line in the original is removed while the perl version seems to just makes it empty -- ah, you remove the trailing LF as well there. I've never seen this done like this, but OK.

It would have been more obvious if it were written like this:
	$_ = "" if ($. == 1);
but probably it is just me.
Thanks for the patch.
Dennis Stosberg· Jun 18, 2006, 22:06 UTC · re: Junio C Hamano · lore

Re: [PATCH] Make t8001-annotate and t8002-blame more portable

Junio C Hamano wrote:
Show 12 quoted lines
> > +    'perl -pi -e "s/^1A.*\n$//; s/^3A/99/" file &&
> >      GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
> 
> The first line in the original is removed while the perl version
> seems to just makes it empty -- ah, you remove the trailing LF
> as well there.  I've never seen this done like this, but OK.
> 
> It would have been more obvious if it were written like this:
> 
> 	$_ = "" if ($. == 1);
> 
> but probably it is just me.

I have no strong preference. Sometimes I find all those magic perl variables like $. $| $, $" and so on hard to distinguish without looking in the manual...

Regards, Dennis

Junio C Hamano· Jun 18, 2006, 22:21 UTC · re: Dennis Stosberg · lore

Re: [PATCH] Make t8001-annotate and t8002-blame more portable

Dennis Stosberg <dennis@stosberg.net> writes:
Show 7 quoted lines
>> It would have been more obvious if it were written like this:
>> 
>> 	$_ = "" if ($. == 1);
>> 
>> but probably it is just me.
>
> I have no strong preference...

Nah, don't worry -- I've already applied your version to my tree.

Alex Riesen· Jun 19, 2006, 16:35 UTC · re: Junio C Hamano · lore

Re: [PATCH] Make t8001-annotate and t8002-blame more portable

On 6/18/06, Junio C Hamano <junkio@cox.net> wrote:
> > +    'perl -pi -e "s/^1A.*\n$//; s/^3A/99/" file &&

activestate perl again: doesn't work without giving a backup file extension, like this: perl -pi.bak -e ...

Dennis Stosberg· Jun 19, 2006, 19:40 UTC · re: Alex Riesen · lore

[PATCH] Fix t8001-annotate and t8002-blame for ActiveState Perl

There seems to be at least one implementation of Perl which requires the user to specify an extension for backup files.

Reported by Alex Riesen.
Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---

What system and what version of ActivePerl do you use? I have just tried ActivePerl 5.8.8 on Solaris and it does _not_ force the user to make backups.

 t/annotate-tests.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/annotate-tests.sh +1 −1
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index c04f0e1..03ed081 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -111,7 +111,7 @@ test_expect_success \
 
 test_expect_success \
     'some edit' \
-    'perl -pi -e "s/^1A.*\n$//; s/^3A/99/" file &&
+    'perl -p -i.orig -e "s/^1A.*\n$//; s/^3A/99/" file &&
     GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
 
 test_expect_success \
-- 
1.4.0

← back to recent threads