git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 21, 2024, 13:50 UTC
Message-ID
<Zfw7FUtDcKBaA0-6@tanuki>
In-Reply-To
<xmqqcys4fj15.fsf@gitster.g>
On Fri, Mar 08, 2024 at 02:36:22PM -0800, Junio C Hamano wrote:
Show 34 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes:
> 
> >> -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.
> 
> Thanks for looking at them carefully.
> 
> In general, when you want to interpolate an variable that exists
> outside test_expect_success, you should write it this way:
> 
> 	for var in a "b c"
> 	do
> 		test_expect_success "message with $var interpolated" '
> 			command and "$var" as its argument
> 		'
> 	done
> 
> The last parameter to test_expect_{success,failure} is eval'ed, so 
> enclose it within a pair of single quotes, and let the eval to
> interpolate references to $variables at runtime (as opposed to when
> the parameters to test_expect_success are formulated) avoids a lot
> of surprises and headaches.
> 
> Perhaps we should have something like the above as a hint in
> t/README?

Makes sense. I've sent a separate patch series addressing this issue in [1].

Thanks!
Patrick
[1]: https://lore.kernel.org/git/cover.1711028473.git.ps@pks.im/
Previous: Junio C Hamano
Message 10 of 10 in “Git difftool: interaction between --dir-diff and --trust-exit-code”
  1. Jean-Rémy FalleriFeb 15, 2024
  2. git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`Patrick Steinhardt, Feb 16, 2024
  3. Junio C HamanoFeb 16, 2024
  4. Patrick SteinhardtFeb 20, 2024
  5. David AguilarFeb 28, 2024
  6. Junio C HamanoFeb 28, 2024
  7. git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`Patrick Steinhardt, Feb 20, 2024
  8. SZEDER GáborMar 8, 2024
  9. Junio C HamanoMar 8, 2024
  10. Patrick SteinhardtMar 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.