threads / patch / 31749

patcht/t5400-send-pack: Use POSIX options to cp for portability

Subject: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

## tl;dr

7 messages between Oct 8, 2012 and Oct 9, 2012. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Ben Walton· Oct 8, 2012, 08:08 UTC · lore

Avoid a GNU-ism in the cp options used by t5400-send-pack. Change -a to -pR.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
---
 t/t5400-send-pack.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to t/t5400-send-pack.sh +1 −1
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 250c720..65b3b0f 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -159,7 +159,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
 	    git commit -a -m "Second commit" &&
 	    git repack
 	) &&
-	cp -a parent child &&
+	cp -pR parent child &&
 	(
 	    # Set the child to auto-pack if more than one pack exists
 	    cd child &&
-- 
1.7.12
Junio C Hamano· Oct 8, 2012, 16:35 UTC · re: Ben Walton · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

Ben Walton <bdwalton@gmail.com> writes:
Show 5 quoted lines
> Avoid a GNU-ism in the cp options used by t5400-send-pack.  Change -a
> to -pR.
>
> Signed-off-by: Ben Walton <bdwalton@gmail.com>
> ---

Thanks, but is "-p" essential for this test to pass, or can we get away with just "-R"?

Show 16 quoted lines
>  t/t5400-send-pack.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
> index 250c720..65b3b0f 100755
> --- a/t/t5400-send-pack.sh
> +++ b/t/t5400-send-pack.sh
> @@ -159,7 +159,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
>  	    git commit -a -m "Second commit" &&
>  	    git repack
>  	) &&
> -	cp -a parent child &&
> +	cp -pR parent child &&
>  	(
>  	    # Set the child to auto-pack if more than one pack exists
>  	    cd child &&
Junio C Hamano· Oct 8, 2012, 16:55 UTC · re: Junio C Hamano · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Ben Walton <bdwalton@gmail.com> writes:
>
>> Avoid a GNU-ism in the cp options used by t5400-send-pack.  Change -a
>> to -pR.
>>
>> Signed-off-by: Ben Walton <bdwalton@gmail.com>
>> ---
>
> Thanks, but is "-p" essential for this test to pass, or can we get
> away with just "-R"?

Besides, when you spot a potential problem, please ask "git grep" to catch them all.

    $ git grep "cp -a" t/
    t/t5400-send-pack.sh:   cp -a parent child &&
    t/t5550-http-fetch.sh:  cp -a .git"$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
    t/t5800-remote-helpers.sh:      cp -a server server2 &&
Show 16 quoted lines
>>  t/t5400-send-pack.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
>> index 250c720..65b3b0f 100755
>> --- a/t/t5400-send-pack.sh
>> +++ b/t/t5400-send-pack.sh
>> @@ -159,7 +159,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
>>  	    git commit -a -m "Second commit" &&
>>  	    git repack
>>  	) &&
>> -	cp -a parent child &&
>> +	cp -pR parent child &&
>>  	(
>>  	    # Set the child to auto-pack if more than one pack exists
>>  	    cd child &&
Junio C Hamano· Oct 8, 2012, 17:45 UTC · re: Junio C Hamano · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
>> Thanks, but is "-p" essential for this test to pass, or can we get
>> away with just "-R"?
>
> Besides, when you spot a potential problem, please ask "git grep"
> to catch them all.
In other words, how about doing this instead?
-- >8 --
Subject: tests: "cp -a" is a GNUism
These tests just wants a bit-for-bit identical copy; they do not
need -H (there is no symbolic link involved) nor -p (there is no
funny permission or ownership issues involved).  Just use "cp -R"
instead.
---
 t/t5400-send-pack.sh      | 2 +-
 t/t5550-http-fetch.sh     | 2 +-
 t/t5800-remote-helpers.sh | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Show changes to 3 files +3 −3

t/t5400-send-pack.sh, t/t5550-http-fetch.sh, t/t5800-remote-helpers.sh

diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 250c720..418f515 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -159,7 +159,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
 	    git commit -a -m "Second commit" &&
 	    git repack
 	) &&
-	cp -a parent child &&
+	cp -R parent child &&
 	(
 	    # Set the child to auto-pack if more than one pack exists
 	    cd child &&
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 16ef041..80d20c8 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -22,7 +22,7 @@ test_expect_success 'setup repository' '
 '
 
 test_expect_success 'create http-accessible bare repository with loose objects' '
-	cp -a .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+	cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 	(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 	 git config core.bare true &&
 	 mkdir -p hooks &&
diff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh
index 5702334..e7dc668 100755
--- a/t/t5800-remote-helpers.sh
+++ b/t/t5800-remote-helpers.sh
@@ -76,7 +76,7 @@ test_expect_success 'pushing to local repo' '
 # git-remote-testgit, but is too slow to leave in for general use.
 : test_expect_success 'racily pushing to local repo' '
 	test_when_finished "rm -rf server2 localclone2" &&
-	cp -a server server2 &&
+	cp -R server server2 &&
 	git clone "testgit::${PWD}/server2" localclone2 &&
 	(cd localclone2 &&
 	echo content >>file &&
-- 
1.8.0.rc0.95.g9b3a052
Ben Walton· Oct 8, 2012, 20:05 UTC · re: Junio C Hamano · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

On Mon, Oct 8, 2012 at 6:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>>> Thanks, but is "-p" essential for this test to pass, or can we get
>>> away with just "-R"?
>>
>> Besides, when you spot a potential problem, please ask "git grep"
>> to catch them all.
>
> In other words, how about doing this instead?

This works. I was responding to a failing test so I didn't look for other instances. Clearly I should have...I must not be exercising those other tests.

Acked-By: Ben Walton <bdwalton@gmail.com>

Thanks -Ben

-- 
---------------------------------------------------------------------------------------------------------------------------
Take the risk of thinking for yourself.  Much more happiness,
truth, beauty and wisdom will come to you that way.

-Christopher Hitchens
---------------------------------------------------------------------------------------------------------------------------
Junio C Hamano· Oct 8, 2012, 21:19 UTC · re: Ben Walton · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

Ben Walton <bdwalton@gmail.com> writes:
Show 16 quoted lines
> On Mon, Oct 8, 2012 at 6:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>>> Thanks, but is "-p" essential for this test to pass, or can we get
>>>> away with just "-R"?
>>>
>>> Besides, when you spot a potential problem, please ask "git grep"
>>> to catch them all.
>>
>> In other words, how about doing this instead?
>
> This works.  I was responding to a failing test so I didn't look for
> other instances.  Clearly I should have...I must not be exercising
> those other tests.
>
> Acked-By: Ben Walton <bdwalton@gmail.com>

I actually was planning to pass the blame to you so I'll re-queue it under your "Author:" name, with S-o-b.

Thanks.
Joachim Schmitz· Oct 9, 2012, 07:15 UTC · re: Junio C Hamano · lore

Re: [PATCH] t/t5400-send-pack: Use POSIX options to cp for portability

Junio C Hamano wrote:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Ben Walton <bdwalton@gmail.com> writes:
>>
>>> Avoid a GNU-ism in the cp options used by t5400-send-pack.  Change
>>> -a
>>> to -pR.
>>>
>>> Signed-off-by: Ben Walton <bdwalton@gmail.com>
>>> ---
>>
>> Thanks, but is "-p" essential for this test to pass, or can we get
>> away with just "-R"?
>
> Besides, when you spot a potential problem, please ask "git grep"
> to catch them all.
>
>    $ git grep "cp -a" t/
>    t/t5400-send-pack.sh:   cp -a parent child &&
>    t/t5550-http-fetch.sh:  cp -a
>    .git"$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
> t/t5800-remote-helpers.sh:      cp -a server server2 &&

There's 2 more places in Documentation/git-tutorial.txt. There it looks like we'd want to use 'cp -pR' instead

Bye, Jojo 

← back to recent threads