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

6 messages from 2006-06-18 to 2006-06-19. Participants: Dennis Stosberg, Junio C Hamano, Alex Riesen.
Thread: https://gitlist.dev/t/4564

## Dennis Stosberg, 2006-06-18 20:33

Subject: [PATCH] Make t8001-annotate and t8002-blame more portable
Message-ID: <20060618203321.G2e8b0080@leonov.stosberg.net>
URL: https://gitlist.dev/e/20060618203321.G2e8b0080%40leonov.stosberg.net

```
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(-)

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, 2006-06-18 20:58

Subject: Re: [PATCH] Make t8001-annotate and t8002-blame more portable
Message-ID: <7v3be218ri.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v3be218ri.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060618203321.G2e8b0080@leonov.stosberg.net>

```
Dennis Stosberg <dennis@stosberg.net> writes:

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

> -    '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, 2006-06-18 22:06

Subject: Re: [PATCH] Make t8001-annotate and t8002-blame more portable
Message-ID: <20060618220654.G4a2f724@leonov.stosberg.net>
URL: https://gitlist.dev/e/20060618220654.G4a2f724%40leonov.stosberg.net
In-Reply-To: <7v3be218ri.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> > +    '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, 2006-06-18 22:21

Subject: Re: [PATCH] Make t8001-annotate and t8002-blame more portable
Message-ID: <7virmydrzx.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7virmydrzx.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060618220654.G4a2f724@leonov.stosberg.net>

```
Dennis Stosberg <dennis@stosberg.net> writes:

>> 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, 2006-06-19 16:35

Subject: Re: [PATCH] Make t8001-annotate and t8002-blame more portable
Message-ID: <81b0412b0606190935g67581ebucf172acb36e53b02@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0606190935g67581ebucf172acb36e53b02%40mail.gmail.com
In-Reply-To: <7v3be218ri.fsf@assigned-by-dhcp.cox.net>

```
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, 2006-06-19 19:40

Subject: [PATCH] Fix t8001-annotate and t8002-blame for ActiveState Perl
Message-ID: <20060619194037.G41ac8efa@leonov.stosberg.net>
URL: https://gitlist.dev/e/20060619194037.G41ac8efa%40leonov.stosberg.net
In-Reply-To: <81b0412b0606190935g67581ebucf172acb36e53b02@mail.gmail.com>

```
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(-)

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

```
