# t5801-remote-helpers.sh fails

7 messages from 2012-11-10 to 2012-11-18. Participants: Torsten Bögershausen, Felipe Contreras.
Thread: https://gitlist.dev/t/32054

## Torsten Bögershausen, 2012-11-10 13:48

Subject: t5801-remote-helpers.sh fails
Message-ID: <509E5B27.5080808@web.de>
URL: https://gitlist.dev/e/509E5B27.5080808%40web.de

```
Hej,
on peff/pu t5801 fails, the error is in git-remote-testgit, please see below.

That's on my Mac OS X box.

I haven't digged further into the test case, but it looks as if 
"[-+]A 	make NAMEs associative arrays"
is not supported on this version of bash.
/Torsten


/Users/tb/projects/git/git.peff/git-remote-testgit: line 64: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/tb/projects/git/git.peff/git-remote-testgit: line 66: refs/heads/master: division by 0 (error token is "/master")
error: fast-export died of signal 13
fatal: Error while running fast-export

```

## Felipe Contreras, 2012-11-10 19:15

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <CAMP44s0HtMRaQ91z95cZS73W7tnqYwyKV_2guWJ6u6UP4p5JNw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s0HtMRaQ91z95cZS73W7tnqYwyKV_2guWJ6u6UP4p5JNw%40mail.gmail.com
In-Reply-To: <509E5B27.5080808@web.de>

```
Hi,

On Sat, Nov 10, 2012 at 2:48 PM, Torsten Bögershausen <tboegi@web.de> wrote:

> on peff/pu t5801 fails, the error is in git-remote-testgit, please see below.
>
> That's on my Mac OS X box.
>
> I haven't digged further into the test case, but it looks as if
> "[-+]A  make NAMEs associative arrays"
> is not supported on this version of bash.
> /Torsten
>
>
> /Users/tb/projects/git/git.peff/git-remote-testgit: line 64: declare: -A: invalid option
> declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
> /Users/tb/projects/git/git.peff/git-remote-testgit: line 66: refs/heads/master: division by 0 (error token is "/master")
> error: fast-export died of signal 13
> fatal: Error while running fast-export

What is your bash --version?

-- 
Felipe Contreras

```

## Torsten Bögershausen, 2012-11-10 19:20

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <509EA8EE.1030908@web.de>
URL: https://gitlist.dev/e/509EA8EE.1030908%40web.de
In-Reply-To: <CAMP44s0HtMRaQ91z95cZS73W7tnqYwyKV_2guWJ6u6UP4p5JNw@mail.gmail.com>

```
On 11/10/2012 08:15 PM, Felipe Contreras wrote:
> Hi,
>
> On Sat, Nov 10, 2012 at 2:48 PM, Torsten Bögershausen <tboegi@web.de> wrote:
>
>> on peff/pu t5801 fails, the error is in git-remote-testgit, please see below.
>>
>> That's on my Mac OS X box.
>>
>> I haven't digged further into the test case, but it looks as if
>> "[-+]A  make NAMEs associative arrays"
>> is not supported on this version of bash.
>> /Torsten
>>
>>
>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 64: declare: -A: invalid option
>> declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 66: refs/heads/master: division by 0 (error token is "/master")
>> error: fast-export died of signal 13
>> fatal: Error while running fast-export
>
> What is your bash --version?
>
  bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.

On the other hand, Documentation/CodingGuidelines says:
   - No shell arrays.

Could we use perl to have arrays?

/Torsten

```

## Felipe Contreras, 2012-11-10 22:05

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <CAMP44s2yenQKSgdUXfZP+yDJJ+bdveyms=SQ+3ptPvpT6D0hsg@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s2yenQKSgdUXfZP%2ByDJJ%2Bbdveyms%3DSQ%2B3ptPvpT6D0hsg%40mail.gmail.com
In-Reply-To: <509EA8EE.1030908@web.de>

```
On Sat, Nov 10, 2012 at 8:20 PM, Torsten Bögershausen <tboegi@web.de> wrote:
> On 11/10/2012 08:15 PM, Felipe Contreras wrote:
>>
>> Hi,
>>
>> On Sat, Nov 10, 2012 at 2:48 PM, Torsten Bögershausen <tboegi@web.de>
>> wrote:
>>
>>> on peff/pu t5801 fails, the error is in git-remote-testgit, please see
>>> below.
>>>
>>> That's on my Mac OS X box.
>>>
>>> I haven't digged further into the test case, but it looks as if
>>> "[-+]A  make NAMEs associative arrays"
>>> is not supported on this version of bash.
>>> /Torsten
>>>
>>>
>>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 64: declare: -A:
>>> invalid option
>>> declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
>>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 66:
>>> refs/heads/master: division by 0 (error token is "/master")
>>> error: fast-export died of signal 13
>>> fatal: Error while running fast-export
>>
>>
>> What is your bash --version?
>>
>  bash --version
> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
> Copyright (C) 2007 Free Software Foundation, Inc.

I see, that version indeed doesn't have associative arrays.

> On the other hand, Documentation/CodingGuidelines says:
>   - No shell arrays.

Yeah, for shell code I guess, but this is bash code.

> Could we use perl to have arrays?

I think the code in perl would be harder to follow, and this is meant
not only as a test, but also as a reference.

I'm not exactly sure what we should do here:

a) remove the code (would not be so good as a reference)
b) enable the code conditionally based on the version of bash (harder to read)
c) replace the code without associative arrays (will be much more
complicated and ugly)
d) add a check for the bash version to the top of the test in t/

I'm leaning towards d), followed by b).

If only there was a clean way to do this, so c) would not be so ugly.

After investigating different optins this seems to be the best:

	join -e empty -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after")
| while read e a b; do
		test "$a" == "$b" && continue
		echo "changed $e"
	done

But to me seems a bit harder to grasp. Not sure.

Cheers.

-- 
Felipe Contreras

```

## Torsten Bögershausen, 2012-11-18 05:50

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <50A87718.4030806@web.de>
URL: https://gitlist.dev/e/50A87718.4030806%40web.de
In-Reply-To: <CAMP44s2yenQKSgdUXfZP+yDJJ+bdveyms=SQ+3ptPvpT6D0hsg@mail.gmail.com>

```
On 10.11.12 23:05, Felipe Contreras wrote:
> On Sat, Nov 10, 2012 at 8:20 PM, Torsten Bögershausen <tboegi@web.de> wrote:
>> On 11/10/2012 08:15 PM, Felipe Contreras wrote:
>>>
>>> Hi,
>>>
>>> On Sat, Nov 10, 2012 at 2:48 PM, Torsten Bögershausen <tboegi@web.de>
>>> wrote:
>>>
>>>> on peff/pu t5801 fails, the error is in git-remote-testgit, please see
>>>> below.
>>>>
>>>> That's on my Mac OS X box.
>>>>
>>>> I haven't digged further into the test case, but it looks as if
>>>> "[-+]A  make NAMEs associative arrays"
>>>> is not supported on this version of bash.
>>>> /Torsten
>>>>
>>>>
>>>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 64: declare: -A:
>>>> invalid option
>>>> declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
>>>> /Users/tb/projects/git/git.peff/git-remote-testgit: line 66:
>>>> refs/heads/master: division by 0 (error token is "/master")
>>>> error: fast-export died of signal 13
>>>> fatal: Error while running fast-export
>>>
>>>
>>> What is your bash --version?
>>>
>>  bash --version
>> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
>> Copyright (C) 2007 Free Software Foundation, Inc.
> 
> I see, that version indeed doesn't have associative arrays.
> 
>> On the other hand, Documentation/CodingGuidelines says:
>>   - No shell arrays.
> 
> Yeah, for shell code I guess, but this is bash code.
> 
>> Could we use perl to have arrays?
> 
> I think the code in perl would be harder to follow, and this is meant
> not only as a test, but also as a reference.
> 
> I'm not exactly sure what we should do here:
> 
> a) remove the code (would not be so good as a reference)
> b) enable the code conditionally based on the version of bash (harder to read)
> c) replace the code without associative arrays (will be much more
> complicated and ugly)
> d) add a check for the bash version to the top of the test in t/
> 
> I'm leaning towards d), followed by b).
> 
> If only there was a clean way to do this, so c) would not be so ugly.
> 
> After investigating different optins this seems to be the best:
> 
> 	join -e empty -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after")
> | while read e a b; do
> 		test "$a" == "$b" && continue
> 		echo "changed $e"
> 	done
> 
> But to me seems a bit harder to grasp. Not sure.
> 
> Cheers.
> 

Hi again,
I managed to have a working solution for
"d) add a check for the bash version to the top of the test in t/"
Please see diff below.

This unbreaks the test suite here.
Is this a good way forward?

Filipe, does the code line you mention above work for you?

If yes: I can test it here, if you send it as a patch.

/Torsten



diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
old mode 100644
new mode 100755
index 6e4e078..ea3d0f3
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -13,6 +13,15 @@ compare_refs() {
        test_cmp expect actual
 }
 
+cat >"testbashArray" <<-EOF
+  declare -A assa
+EOF
+
+/bin/bash testbashArray || {
+       skip_all='t5801. /bin/bash does not handle associative arrays'
+       test_done
+}
+
 test_expect_success 'setup repository' '
        git init server &&
        (cd server &&

```

## Felipe Contreras, 2012-11-18 08:23

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <CAMP44s22kuXqUjY2Oy2YtBfj1+kF2rHnRKcovV8sPkhu1oR+2A@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s22kuXqUjY2Oy2YtBfj1%2BkF2rHnRKcovV8sPkhu1oR%2B2A%40mail.gmail.com
In-Reply-To: <50A87718.4030806@web.de>

```
Hi,

On Sun, Nov 18, 2012 at 6:50 AM, Torsten Bögershausen <tboegi@web.de> wrote:

> I managed to have a working solution for
> "d) add a check for the bash version to the top of the test in t/"
> Please see diff below.
>
> This unbreaks the test suite here.
> Is this a good way forward?
>
> Filipe, does the code line you mention above work for you?
>
> If yes: I can test it here, if you send it as a patch.

It's already sent:
http://article.gmane.org/gmane.comp.version-control.git/209364

-- 
Felipe Contreras

```

## Torsten Bögershausen, 2012-11-18 15:52

Subject: Re: t5801-remote-helpers.sh fails
Message-ID: <50A9043B.6070904@web.de>
URL: https://gitlist.dev/e/50A9043B.6070904%40web.de
In-Reply-To: <CAMP44s22kuXqUjY2Oy2YtBfj1+kF2rHnRKcovV8sPkhu1oR+2A@mail.gmail.com>

```
On 18.11.12 09:23, Felipe Contreras wrote:
> Hi,
> 
> On Sun, Nov 18, 2012 at 6:50 AM, Torsten Bögershausen <tboegi@web.de> wrote:
> 
>> I managed to have a working solution for
>> "d) add a check for the bash version to the top of the test in t/"
>> Please see diff below.
>>
>> This unbreaks the test suite here.
>> Is this a good way forward?
>>
>> Filipe, does the code line you mention above work for you?
>>
>> If yes: I can test it here, if you send it as a patch.
> 
> It's already sent:
> http://article.gmane.org/gmane.comp.version-control.git/209364
> 
Thanks for working on it, and sorry that you need to remind me:
I had the V5 series already on my harddisk, but forgot to test it.
It applied on v.1.8.0 with the following results:

ok 1 - setup repository
ok 2 - cloning from local repo
ok 3 - create new commit on remote
ok 4 - pulling from local repo
ok 5 - pushing to local repo
ok 6 - fetch new branch
ok 7 - fetch multiple branches
ok 8 - push when remote has extra refs
ok 9 - push new branch by name
not ok 10 - push new branch with old:new refspec # TODO known breakage
ok 11 - cloning without refspec
ok 12 - pulling without refspecs
not ok 13 - pushing without refspecs # TODO known breakage
not ok 14 - pulling with straight refspec # TODO known breakage
not ok 15 - pushing with straight refspec # TODO known breakage
not ok 16 - pulling without marks # TODO known breakage
not ok 17 - pushing without marks # TODO known breakage
ok 18 - push ref with existing object
# still have 6 known breakage(s)
/Torsten

```
