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

Re: [PATCH] for-each-repo: do nothing on empty config

From
Derrick Stolee <stolee@gmail.com>
Date
Jan 7, 2021, 02:00 UTC
Message-ID
<441209e0-2102-b055-867a-1b4747499181@gmail.com>
In-Reply-To
<xmqqv9c9pwv0.fsf@gitster.c.googlers.com>
On 1/6/2021 4:40 PM, Junio C Hamano wrote:
Show 44 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Derrick Stolee <stolee@gmail.com> writes:
>>
>>>> I wonder if "false" or "exit 1" would fit the bill.  In any case, a
>>>> comment may help, perhaps?
>>>>
>>>> 	test_expect_success 'do nothing and succeed on empty/missing config' '
>>>> 		# if this runs even once, "false" ensures a failure
>>>> 		git for-each-repo --config=bogus.config -- false
>>>> 	'
>>>
>>> I can add a comment, but keep in mind that this example would run the
>>> subcommand as "git false". This isn't intended as an arbitrary script
>>> runner, but a "please run the same Git command on a list of repos".
>>
>> Ah, that is a good point.
>>
>> The comment needs to explain:
>>
>> 	# the command fails if it attempts to run even once because
>> 	# 'git false' does not exist
>>
>> and at that point, it does not have to be spelled 'false'.  It could
>> be 'no-such-git-subcommand' (and I wonder if that makes the comment
>> unnecessary).
>>
>> That reminds me.  If I have ~/bin/git-false and ~/bin on my $PATH,
>> would this test fail to catch breakage?
> 
> Yes, I think $PATH in the test environment starts from the original
> $PATH and modified only by prepending, so my ~/bin/git-false would
> kick in.  We cannot reliably depend on the absence of a subcommand.
> 
> We can instead use
> 
> 	# the whole thing would fail if for-each-ref iterated even
> 	# once, because 'git help --no-such-option' would fail
> 	git for-each-ref --config=<var> -- help --no-such-option
> 
> and I think that would be much more reliable; if an invocation of
> "git help" inside our test suite fails to refer to the "git help"
> from the version of Git being tested, we already have a serious
> problem.
A very good point. I'll include this in v3.

Thanks, -Stolee

Previous: Junio C HamanoNext: Derrick Stolee via GitGitGadget
Message 13 of 15 in “for-each-repo: do nothing on empty config”
  1. for-each-repo: do nothing on empty configDerrick Stolee via GitGitGadget, Jan 5, 2021
  2. Eric SunshineJan 5, 2021
  3. Derrick StoleeJan 6, 2021
  4. Eric SunshineJan 6, 2021
  5. Derrick StoleeJan 6, 2021
  6. Eric SunshineJan 6, 2021
  7. Junio C HamanoJan 6, 2021
  8. Eric SunshineJan 7, 2021
  9. Junio C HamanoJan 6, 2021
  10. Derrick StoleeJan 6, 2021
  11. Junio C HamanoJan 6, 2021
  12. Junio C HamanoJan 6, 2021
  13. Derrick StoleeJan 7, 2021
  14. for-each-repo: do nothing on empty configDerrick Stolee via GitGitGadget, Jan 6, 2021
  15. for-each-repo: do nothing on empty configDerrick Stolee via GitGitGadget, Jan 8, 2021

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.