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

Re: [PATCH] multi-pack-index: fix --object-dir from outside repo

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2021, 16:16 UTC
Message-ID
<xmqqwnocqgqm.fsf@gitster.g>
In-Reply-To
<746f574d20c54b5f7d1eaae74f54a624573ad6bc.camel@sipsolutions.net>
Johannes Berg <johannes@sipsolutions.net> writes:
Show 19 quoted lines
> On Mon, 2021-08-23 at 09:19 -0400, Derrick Stolee wrote:
>> 
>> We just add subshells this way:
>> 
>> test_expect_success 'test name' '
>> 	prep_step &&
>> 	(
>> 		# now in a subshell
>> 		cd wherever &&
>> 		do things
>> 		# don't need to cd again
>> 	) &&
>> 	continue test
>> '
>
> Sure. I know how to do subshells :)
>
> My point was that inside the subshell you cannot do test_path_is_file
> and similar, because the subshell didn't import the libs.

Everything the call to prep_step, and anything that came before that call, did to the environment, like setting shell functions and variables, is visible inside the ( ... subshell ... ).

> I was specifically asking Junio ;-)
>
> But realistically, if this is the requirement you want to impose, then
> you _cannot_ test for the segfault within git's test suite. Your loss.
With that "cannot", I think you are assuming too much.  

Because Git is a fairly long-lived project, we've had our share of cases where we needed to test for bugs that happen only when outside a repository.

And we have facility for just that, it's called "nongit" test helper that comes from test-lib-functions.sh, which is dot-included already so your subshells get it for free.

t5300-pack-object.sh, for example, wants to make sure that the "git index-pack --stdin" command invoked in a directory that is not a repository, but "git index-pack <packfile>" works outside a repository, and has two tests that uses the nongit helper.

Thanks.
Previous: Johannes BergNext: Junio C Hamano
Message 8 of 11 in “multi-pack-index: fix --object-dir from outside repo”
  1. multi-pack-index: fix --object-dir from outside repoJohannes Berg, Aug 20, 2021
  2. Derrick StoleeAug 22, 2021
  3. Johannes BergAug 23, 2021
  4. Junio C HamanoAug 23, 2021
  5. Johannes BergAug 23, 2021
  6. Derrick StoleeAug 23, 2021
  7. Johannes BergAug 23, 2021
  8. Junio C HamanoAug 23, 2021
  9. Junio C HamanoAug 23, 2021
  10. Taylor BlauAug 23, 2021
  11. Johannes BergAug 23, 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.