git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.keller@gmail.com>
Cc: git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>,
	Jacob Keller <jacob.e.keller@intel.com>
Subject: Re: [PATCH v2 1/5] t5505: remove sub shell use in favor of git -C
Date: Thu, 16 Jun 2022 14:09:15 -0700	[thread overview]
Message-ID: <xmqq8rpws4ck.fsf@gitster.g> (raw)
In-Reply-To: <20220616205456.19081-2-jacob.e.keller@intel.com> (Jacob Keller's message of "Thu, 16 Jun 2022 13:54:52 -0700")

Jacob Keller <jacob.keller@gmail.com> writes:

>  check_remote_track () {
> -	actual=$(git remote show "$1" | sed -ne 's|^    \(.*\) tracked$|\1|p')
> +	actual=$(git -C test remote show "$1" | sed -ne 's|^    \(.*\) tracked$|\1|p')

This has become less generic.

>  	shift &&
>  	tokens_match "$*" "$actual"
>  }
>  
>  check_tracking_branch () {
>  	f="" &&
> -	r=$(git for-each-ref "--format=%(refname)" |
> +	r=$(git -C test for-each-ref "--format=%(refname)" |
>  		sed -ne "s|^refs/remotes/$1/||p") &&

Likewise.

They used to be usable in any test repository, but now they have to
be used in a repository whose name is "test".

I wonder if something like

	check_foo () {
		if test "$1" = -C
		then
			in_repo=$2
			shift 2
		else
			in_repo=
		fi &&
		actual=$(git ${in_repo:+-C "$in_repo"} subcmd ...) &&
		do things ... &&
		do more things
	}

would work better?  

> @@ -44,10 +44,7 @@ check_tracking_branch () {
>  test_expect_success setup '
>  	setup_repository one &&
>  	setup_repository two &&
> -	(
> -		cd two &&
> -		git branch another
> -	) &&
> +	git -C two branch another &&
>  	git clone one test
>  '

Clear improvement.

> @@ -57,25 +54,19 @@ test_expect_success 'add remote whose URL agrees with url.<...>.insteadOf' '
>  '
>  
>  test_expect_success 'remote information for the origin' '
> -	(
> -		cd test &&
> -		tokens_match origin "$(git remote)" &&
> -		check_remote_track origin main side &&
> -		check_tracking_branch origin HEAD main side
> -	)
> +	tokens_match origin "$(git -C test remote)" &&

This is a clear improvement.

> +	check_remote_track origin main side &&
> +	check_tracking_branch origin HEAD main side

These two are a bit questionable (it hides the fact that all these
names refer to stuff in "test" subdirectory).


  reply	other threads:[~2022-06-16 21:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 20:54 [PATCH v2 0/5] support negative refspecs in git remote show Jacob Keller
2022-06-16 20:54 ` [PATCH v2 1/5] t5505: remove sub shell use in favor of git -C Jacob Keller
2022-06-16 21:09   ` Junio C Hamano [this message]
2022-06-16 21:10     ` Jacob Keller
2022-06-16 20:54 ` [PATCH v2 2/5] tests: handle --global directly in test_config/test_unconfig Jacob Keller
2022-06-16 21:34   ` Junio C Hamano
2022-06-16 22:08     ` Jacob Keller
2022-06-16 20:54 ` [PATCH v2 3/5] tests: only automatically unset matching values from test_config Jacob Keller
2022-06-16 21:18   ` Junio C Hamano
2022-06-16 22:07     ` Jacob Keller
2022-06-16 20:54 ` [PATCH v2 4/5] t5505: use test_config where appropriate Jacob Keller
2022-06-16 20:54 ` [PATCH v2 5/5] remote: handle negative refspecs in git remote show Jacob Keller
2022-06-16 21:31 ` [PATCH v2 0/5] support " Junio C Hamano
2022-06-16 22:08   ` Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8rpws4ck.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jacob.keller@gmail.com \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).