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
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2024, 22:36 UTC
Message-ID
<xmqqcys4fj15.fsf@gitster.g>
In-Reply-To
<20240308221229.GA1908@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 11 quoted lines
>> -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?

Previous: SZEDER GáborNext: Patrick Steinhardt
Message 9 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.