All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, "Jean-Rémy Falleri" <jr.falleri@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v2] git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`
Date: Fri, 8 Mar 2024 23:12:29 +0100	[thread overview]
Message-ID: <20240308221229.GA1908@szeder.dev> (raw)
In-Reply-To: <0fac668f8fc021af9f9c4df5134da59816307ccc.1708423309.git.ps@pks.im>

On Tue, Feb 20, 2024 at 11:08:25AM +0100, Patrick Steinhardt wrote:
> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index 6a36be1e63..96ae5d5880 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -91,58 +91,67 @@ test_expect_success 'difftool forwards arguments to diff' '
>  	rm for-diff
>  '
>  
> -test_expect_success 'difftool ignores exit code' '
> -	test_config difftool.error.cmd false &&
> -	git difftool -y -t error branch
> -'
> +for opt in '' '--dir-diff'
> +do
> +	test_expect_success "difftool ${opt} ignores exit code" "
> +		test_config difftool.error.cmd false &&
> +		git difftool ${opt} -y -t error branch
> +	"
>  
> -test_expect_success 'difftool forwards exit code with --trust-exit-code' '
> -	test_config difftool.error.cmd false &&
> -	test_must_fail git difftool -y --trust-exit-code -t error branch
> -'
> +	test_expect_success "difftool ${opt} forwards exit code with --trust-exit-code" "
> +		test_config difftool.error.cmd false &&
> +		test_must_fail git difftool ${opt} -y --trust-exit-code -t error branch
> +	"
>  
> -test_expect_success 'difftool forwards exit code with --trust-exit-code for built-ins' '
> -	test_config difftool.vimdiff.path false &&
> -	test_must_fail git difftool -y --trust-exit-code -t vimdiff branch
> -'
> +	test_expect_success "difftool ${opt} forwards exit code with --trust-exit-code for built-ins" "
> +		test_config difftool.vimdiff.path false &&
> +		test_must_fail git difftool ${opt} -y --trust-exit-code -t vimdiff branch
> +	"
>  
> -test_expect_success 'difftool honors difftool.trustExitCode = true' '
> -	test_config difftool.error.cmd false &&
> -	test_config difftool.trustExitCode true &&
> -	test_must_fail git difftool -y -t error branch
> -'
> +	test_expect_success "difftool ${opt} honors difftool.trustExitCode = true" "
> +		test_config difftool.error.cmd false &&
> +		test_config difftool.trustExitCode true &&
> +		test_must_fail git difftool ${opt} -y -t error branch
> +	"
>  
> -test_expect_success 'difftool honors difftool.trustExitCode = false' '
> -	test_config difftool.error.cmd false &&
> -	test_config difftool.trustExitCode false &&
> -	git difftool -y -t error branch
> -'
> +	test_expect_success "difftool ${opt} honors difftool.trustExitCode = false" "
> +		test_config difftool.error.cmd false &&
> +		test_config difftool.trustExitCode false &&
> +		git difftool ${opt} -y -t error branch
> +	"
>  
> -test_expect_success 'difftool ignores exit code with --no-trust-exit-code' '
> -	test_config difftool.error.cmd false &&
> -	test_config difftool.trustExitCode true &&
> -	git difftool -y --no-trust-exit-code -t error branch
> -'
> +	test_expect_success "difftool ${opt} ignores exit code with --no-trust-exit-code" "
> +		test_config difftool.error.cmd false &&
> +		test_config difftool.trustExitCode true &&
> +		git difftool ${opt} -y --no-trust-exit-code -t error branch
> +	"
>  
> -test_expect_success 'difftool stops on error with --trust-exit-code' '
> -	test_when_finished "rm -f for-diff .git/fail-right-file" &&
> -	test_when_finished "git reset -- for-diff" &&
> -	write_script .git/fail-right-file <<-\EOF &&
> -	echo failed
> -	exit 1
> -	EOF
> -	>for-diff &&
> -	git add for-diff &&
> -	test_must_fail git difftool -y --trust-exit-code \
> -		--extcmd .git/fail-right-file branch >actual &&
> -	test_line_count = 1 actual
> -'
> +	test_expect_success "difftool ${opt} stops on error with --trust-exit-code" "
> +		test_when_finished 'rm -f for-diff .git/fail-right-file' &&
> +		test_when_finished 'git reset -- for-diff' &&
> +		write_script .git/fail-right-file <<-\EOF &&
> +		echo failed
> +		exit 1
> +		EOF
> +		>for-diff &&
> +		git add for-diff &&
> +		test_must_fail git difftool ${opt} -y --trust-exit-code \
> +			--extcmd .git/fail-right-file branch >actual &&
> +		test_line_count = 1 actual
> +	"
>  
> -test_expect_success 'difftool honors exit status if command not found' '
> -	test_config difftool.nonexistent.cmd i-dont-exist &&
> -	test_config difftool.trustExitCode false &&
> -	test_must_fail git difftool -y -t nonexistent branch
> -'
> +	test_expect_success "difftool ${opt} honors exit status if command not found" "
> +		test_config difftool.nonexistent.cmd i-dont-exist &&
> +		test_config difftool.trustExitCode false &&
> +		if test "${opt}" = '--dir-diff'

The quoting doesn't quite work here.  When $opt is empty, this results
in:

  expecting success of 7800.14 'difftool  honors exit status if command not found':
                  test_config difftool.nonexistent.cmd i-dont-exist &&
                  test_config difftool.trustExitCode false &&
                  if test  = '--dir-diff'
                  then
                          expected_code=127
                  else
                          expected_code=128
                  fi &&
                  test_expect_code ${expected_code} git difftool  -y -t nonexistent branch
  
  + test_config difftool.nonexistent.cmd i-dont-exist
  + test_config difftool.trustExitCode false
  + test = --dir-diff
  ./t7800-difftool.sh: 14: test: =: unexpected operator


> +		then
> +			expected_code=127
> +		else
> +			expected_code=128
> +		fi &&
> +		test_expect_code \${expected_code} git difftool ${opt} -y -t nonexistent branch
> +	"
> +done
>  
>  test_expect_success 'difftool honors --gui' '
>  	difftool_test_setup &&
> -- 
> 2.44.0-rc1
> 



  reply	other threads:[~2024-03-08 22:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 11:09 Git difftool: interaction between --dir-diff and --trust-exit-code Jean-Rémy Falleri
2024-02-16  8:39 ` [PATCH] git-difftool--helper: honor `--trust-exit-code` with `--dir-diff` Patrick Steinhardt
2024-02-16 18:12   ` Junio C Hamano
2024-02-20  9:56     ` Patrick Steinhardt
2024-02-28  1:52     ` David Aguilar
2024-02-28  2:15       ` Junio C Hamano
2024-02-20 10:08 ` [PATCH v2] " Patrick Steinhardt
2024-03-08 22:12   ` SZEDER Gábor [this message]
2024-03-08 22:36     ` Junio C Hamano
2024-03-21 13:50       ` Patrick Steinhardt

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=20240308221229.GA1908@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jr.falleri@gmail.com \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.