# [PATCH/RFC] t0060: basename("//") is implementation defined

4 messages from 2016-01-13 to 2016-01-14. Participants: tboegi@web.de, Junio C Hamano, Johannes Schindelin, Torsten Bögershausen.
Thread: https://gitlist.dev/t/41185

## tboegi@web.de, 2016-01-13 20:56

Subject: [PATCH/RFC] t0060: basename("//") is implementation defined
Message-ID: <1452718561-32226-1-git-send-email-tboegi@web.de>
URL: https://gitlist.dev/e/1452718561-32226-1-git-send-email-tboegi%40web.de

```
From: Torsten Bögershausen <tboegi@web.de>

From
http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html
basename("//") may return either "//" or "/".

Linux returns "/", some systems like Mac OS X return "//".
Skip the test unless NO_LIBGEN_H is set and gitbasename() from
compat/basename is used.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
My version of a hot fix
 test-path-utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test-path-utils.c b/test-path-utils.c
index 4ab68ac..db0bb39 100644
--- a/test-path-utils.c
+++ b/test-path-utils.c
@@ -142,7 +142,9 @@ static struct test_data dirname_data[] = {
 	{ ".",               "."      },
 	{ "..",              "."      },
 	{ "/",               "/"      },
+#if defined(NO_LIBGEN_H)
 	{ "//",              "//"     },
+#endif
 #if defined(__CYGWIN__) && !defined(NO_LIBGEN_H)
 	{ "///",             "//"     },
 	{ "////",            "//"     },
-- 
2.7.0.278.g9379adb.dirty

```

## Junio C Hamano, 2016-01-13 21:16

Subject: Re: [PATCH/RFC] t0060: basename("//") is implementation defined
Message-ID: <xmqqegdlmb7f.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqegdlmb7f.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1452718561-32226-1-git-send-email-tboegi@web.de>

```
tboegi@web.de writes:

> From: Torsten Bögershausen <tboegi@web.de>
>
> From
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html
> basename("//") may return either "//" or "/".
>
> Linux returns "/", some systems like Mac OS X return "//".
> Skip the test unless NO_LIBGEN_H is set and gitbasename() from
> compat/basename is used.
>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
> My version of a hot fix
>  test-path-utils.c | 2 ++
>  1 file changed, 2 insertions(+)

Thanks.  Ramsay gave a nice analysis at

  http://thread.gmane.org/gmane.comp.version-control.git/283928

and Dscho already is working on it, IIUC, in a slightly different
direction.

> diff --git a/test-path-utils.c b/test-path-utils.c
> index 4ab68ac..db0bb39 100644
> --- a/test-path-utils.c
> +++ b/test-path-utils.c
> @@ -142,7 +142,9 @@ static struct test_data dirname_data[] = {
>  	{ ".",               "."      },
>  	{ "..",              "."      },
>  	{ "/",               "/"      },
> +#if defined(NO_LIBGEN_H)
>  	{ "//",              "//"     },
> +#endif
>  #if defined(__CYGWIN__) && !defined(NO_LIBGEN_H)
>  	{ "///",             "//"     },
>  	{ "////",            "//"     },

```

## Johannes Schindelin, 2016-01-14 07:00

Subject: Re: [PATCH/RFC] t0060: basename("//") is implementation defined
Message-ID: <alpine.DEB.2.20.1601140758420.2964@virtualbox>
URL: https://gitlist.dev/e/alpine.DEB.2.20.1601140758420.2964%40virtualbox
In-Reply-To: <1452718561-32226-1-git-send-email-tboegi@web.de>

```
Hi Torsten,

On Wed, 13 Jan 2016, tboegi@web.de wrote:

> diff --git a/test-path-utils.c b/test-path-utils.c
> index 4ab68ac..db0bb39 100644
> --- a/test-path-utils.c
> +++ b/test-path-utils.c
> @@ -142,7 +142,9 @@ static struct test_data dirname_data[] = {
>  	{ ".",               "."      },
>  	{ "..",              "."      },
>  	{ "/",               "/"      },
> +#if defined(NO_LIBGEN_H)
>  	{ "//",              "//"     },
> +#endif

This would miss faulty implementations that return completely bogus
outputs for the "//" input. Not very likely, I agree, but the entire
intention of this regression test is to verify that Git's expectations are
met (and to document those expectations).

I hope you like the alternative patch I just sent out.

Ciao,
Dscho

```

## Torsten Bögershausen, 2016-01-14 11:47

Subject: Re: [PATCH/RFC] t0060: basename("//") is implementation defined
Message-ID: <56978ADF.5040401@web.de>
URL: https://gitlist.dev/e/56978ADF.5040401%40web.de
In-Reply-To: <alpine.DEB.2.20.1601140758420.2964@virtualbox>

```
On 01/14/2016 08:00 AM, Johannes Schindelin wrote:
> Hi Torsten,
>
> On Wed, 13 Jan 2016, tboegi@web.de wrote:
>
>> diff --git a/test-path-utils.c b/test-path-utils.c
>> index 4ab68ac..db0bb39 100644
>> --- a/test-path-utils.c
>> +++ b/test-path-utils.c
>> @@ -142,7 +142,9 @@ static struct test_data dirname_data[] = {
>>   	{ ".",               "."      },
>>   	{ "..",              "."      },
>>   	{ "/",               "/"      },
>> +#if defined(NO_LIBGEN_H)
>>   	{ "//",              "//"     },
>> +#endif
> This would miss faulty implementations that return completely bogus
> outputs for the "//" input. Not very likely, I agree, but the entire
> intention of this regression test is to verify that Git's expectations are
> met (and to document those expectations).
>
> I hope you like the alternative patch I just sent out.
Yepp, looks good. Thanks for the work.

```
