# [PATCH] t/t7300: workaround ancient touch by rearranging arguments

5 messages from 2010-09-15 to 2010-09-18. Participants: Brandon Casey, Junio C Hamano, Jeff King, Sverre Rabbelier.
Thread: https://gitlist.dev/t/25114

## Brandon Casey, 2010-09-15 20:58

Subject: [PATCH] t/t7300: workaround ancient touch by rearranging arguments
Message-ID: <i6Vnwbi85zvoD6Nzpw2lc1cAb4fZRJiU13x2r3wnIFnHDZWo9gkMwp9pRXJjgiXl4Ce-ERc-tvc@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/i6Vnwbi85zvoD6Nzpw2lc1cAb4fZRJiU13x2r3wnIFnHDZWo9gkMwp9pRXJjgiXl4Ce-ERc-tvc%40cipher.nrlssc.navy.mil

```
From: Brandon Casey <drafnel@gmail.com>

The ancient touch on Solaris 7 thinks that a decimal number supplied as
the first argument specifies a date_time to give to the files specified by
the remaining arguments.  In this case, it fails to parse '1' as a proper
date_time and exits with a failure status.  Workaround this flaw by
rearranging the arguments supplied to touch so that a non-digit appears
first and touch will not be confused.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t7300-clean.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 7dbbea1..6c776e9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -443,7 +443,7 @@ test_expect_success 'git clean -e' '
 	(
 		cd repo &&
 		git init &&
-		touch 1 2 3 known &&
+		touch known 1 2 3 &&
 		git add known &&
 		git clean -f -e 1 -e 2 &&
 		test -e 1 &&
-- 
1.7.2.1

```

## Junio C Hamano, 2010-09-15 22:08

Subject: Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments
Message-ID: <7vocby64oi.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vocby64oi.fsf%40alter.siamese.dyndns.org
In-Reply-To: <i6Vnwbi85zvoD6Nzpw2lc1cAb4fZRJiU13x2r3wnIFnHDZWo9gkMwp9pRXJjgiXl4Ce-ERc-tvc@cipher.nrlssc.navy.mil>

```
Brandon Casey <casey@nrlssc.navy.mil> writes:

> From: Brandon Casey <drafnel@gmail.com>
>
> The ancient touch on Solaris 7 thinks that a decimal number supplied as
> the first argument specifies a date_time to give to the files specified by
> the remaining arguments.  In this case, it fails to parse '1' as a proper
> date_time and exits with a failure status.  Workaround this flaw by
> rearranging the arguments supplied to touch so that a non-digit appears
> first and touch will not be confused.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>

Yuck, there were other reasons why I tend to write ">file" in our tests,
just to create a new and empty file, but I didn't remember seeing this
one.  It's been a while since I touched Solaris the last time.

Thanks for catching.

>  t/t7300-clean.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> index 7dbbea1..6c776e9 100755
> --- a/t/t7300-clean.sh
> +++ b/t/t7300-clean.sh
> @@ -443,7 +443,7 @@ test_expect_success 'git clean -e' '
>  	(
>  		cd repo &&
>  		git init &&
> -		touch 1 2 3 known &&
> +		touch known 1 2 3 &&
>  		git add known &&
>  		git clean -f -e 1 -e 2 &&
>  		test -e 1 &&
> -- 
> 1.7.2.1

```

## Jeff King, 2010-09-16 00:31

Subject: Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments
Message-ID: <20100916003117.GA2527@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20100916003117.GA2527%40sigill.intra.peff.net
In-Reply-To: <i6Vnwbi85zvoD6Nzpw2lc1cAb4fZRJiU13x2r3wnIFnHDZWo9gkMwp9pRXJjgiXl4Ce-ERc-tvc@cipher.nrlssc.navy.mil>

```
On Wed, Sep 15, 2010 at 03:58:22PM -0500, Brandon Casey wrote:

> From: Brandon Casey <drafnel@gmail.com>
> 
> The ancient touch on Solaris 7 thinks that a decimal number supplied as
> the first argument specifies a date_time to give to the files specified by
> the remaining arguments.  In this case, it fails to parse '1' as a proper
> date_time and exits with a failure status.  Workaround this flaw by
> rearranging the arguments supplied to touch so that a non-digit appears
> first and touch will not be confused.

Hmm, this seemed eerily familiar, and sure enough:

  http://article.gmane.org/gmane.comp.version-control.git/101270

I don't _think_ I had Solaris 7 anytime recently, so the issue may be
even more widespread (I would guess that my patch was a result of
Solaris 8). Anyway, good catch.

-Peff

```

## Sverre Rabbelier, 2010-09-17 23:26

Subject: Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments
Message-ID: <AANLkTinKxSugWedXxLPkSUKyRBBkTimawVY23+A5nzsZ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinKxSugWedXxLPkSUKyRBBkTimawVY23%2BA5nzsZ%40mail.gmail.com
In-Reply-To: <20100916003117.GA2527@sigill.intra.peff.net>

```
Heya,

On Thu, Sep 16, 2010 at 02:31, Jeff King <peff@peff.net> wrote:
> Hmm, this seemed eerily familiar, and sure enough:
>
>  http://article.gmane.org/gmane.comp.version-control.git/101270

Does this call for a git_touch which does a regular 'touch' for each
of its arguments?

-- 
Cheers,

Sverre Rabbelier

```

## Jeff King, 2010-09-18 03:46

Subject: Re: [PATCH] t/t7300: workaround ancient touch by rearranging arguments
Message-ID: <20100918034619.GA18343@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20100918034619.GA18343%40sigill.intra.peff.net
In-Reply-To: <AANLkTinKxSugWedXxLPkSUKyRBBkTimawVY23+A5nzsZ@mail.gmail.com>

```
On Sat, Sep 18, 2010 at 01:26:25AM +0200, Sverre Rabbelier wrote:

> On Thu, Sep 16, 2010 at 02:31, Jeff King <peff@peff.net> wrote:
> > Hmm, this seemed eerily familiar, and sure enough:
> >
> >  http://article.gmane.org/gmane.comp.version-control.git/101270
> 
> Does this call for a git_touch which does a regular 'touch' for each
> of its arguments?

I don't know the broken touch's behavior, and I don't have it handy. It
might handle "touch 1" fine or it might interpret it as "touch at time
1, no file arguments". Brandon's solution is good enough for a test
script.

If you really wanted a portable git_touch, you would spell it ">>$file".

-Peff

```
