Subject: Re: [PATCH v3 00/11] document & test fetch pruning & add fetch.pruneTags

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Tue, 06 Feb 2018 17:23:25 +0100

On Tue, Jan 23 2018, Ævar Arnfjörð Bjarmason jotted:

> I'm now just skipping quoting things like +refs/... on the
> command-line, which as grepping the rest of the test suite shows is
> fine, this eliminated the need for "fetch tests: double quote a
> variable for interpolation" so I've ejected it.

There's a segfault bug in 11/11, which wasn't found because the test
suite doesn't test `git fetch <url>` just `git fetch <named>` and this
is handled differently.

I'll send a fix soon, but don't merge this down from pu for now.

In order to test for that I brought that cmdline quoting patch back, I
can't find a better way to do that, and in addition I have this similar
WIP patch:

    diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
    index 2f5bd966be..8fe4f3c13b 100755
    --- a/t/t5510-fetch.sh
    +++ b/t/t5510-fetch.sh
    @@ -549,13 +549,39 @@ set_config_tristate () {
     }

     test_configured_prune () {
    +	test_configured_prune_guts "$@" "name"
    +	test_configured_prune_guts "$@" "link"
    +}
    +
    +test_configured_prune_guts () {
     	fetch_prune=$1
     	remote_origin_prune=$2
     	expected_branch=$3
     	expected_tag=$4
     	cmdline=$5
    -
    -	test_expect_success "prune fetch.prune=$1 remote.origin.prune=$2${5:+ $5}; branch:$3 tag:$4" '
    +	mode=$6
    +
    +	if ! test -e prune-guts-setup
    +	then
    +		test_expect_success 'prune_guts setup' '
    +			git -C one config remote.origin.url >one.remote-url &&
    +			git -C one config remote.origin.fetch >one.remote-fetch &&
    +			touch prune-guts-setup
    +		'
    +	fi
    +
    +	if test "$mode" = 'link'
    +	then
    +		remote_url="file://$(cat one.remote-url)"
    +		remote_fetch="$(cat one.remote-fetch)"
    +		cmdline_setup="\"$remote_url\" \"$remote_fetch\""
    +		if test "$cmdline" != ""
    +		then
    +			cmdline=$(printf "%s" "$cmdline" | sed -e 's! origin! "'"$remote_url"'"!g')
    +		fi
    +	fi
    +
    +	test_expect_success "$mode prune fetch.prune=$1 remote.origin.prune=$2${5:+ $5}; branch:$3 tag:$4" '
     		# make sure a newbranch is there in . and also in one
     		git branch -f newbranch &&
     		git tag -f newtag &&
    @@ -563,7 +589,7 @@ test_configured_prune () {
     			cd one &&
     			test_unconfig fetch.prune &&
     			test_unconfig remote.origin.prune &&
    -			git fetch &&
    +			git fetch '"$cmdline_setup"' &&
     			git rev-parse --verify refs/remotes/origin/newbranch &&
     			git rev-parse --verify refs/tags/newtag
     		) &&

It'll be amended a bit more, but the general idea is there, because of
how this whole quoting mess looks like I have to resort to the above
hack outside of the test setup.