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
Derrick Stolee <stolee@gmail.com>
Date
Aug 22, 2021, 23:51 UTC
Message-ID
<04ed58aa-94fa-010e-f4db-f41cd51876a5@gmail.com>
In-Reply-To
<20210820193504.37044-1-johannes@sipsolutions.net>
On 8/20/2021 3:35 PM, Johannes Berg wrote:
> If using --object-dir to point into a repo, 'write' will
> segfault trying to access the object-dir via the repo it
> found, but that's not fully initialized. Fix it to use
> the object_dir properly.

Thanks for finding this! It's difficult to cover all of the cases, but I'm glad you found this and added a test.

Show 6 quoted lines
> +test_expect_success 'multi-pack-index with --object-dir need not be in repo' '
> +	p="$(pwd)" &&
> +	rm -f $objdir/multi-pack-index &&
> +	cd / &&
> +	git multi-pack-index --object-dir="$p/$objdir" write &&
> +	cd "$p"

Why are you using "cd /" here? Even if you mean to use "cd", please do so within a sub-shell.

Could you instead init a new repo within the current directory and point the object-dir to that location?

It could look something like this, (warning: I did not test this)
	git init other &&
	test_commit -C other first &&
	git multi-pack-index --object-dir=other/.git/objects write

And is the only post-condition you are checking that we do not crash? Or is there a specific result you are looking for? For instance, we can double check that the MIDX was written:

	test_path_is_file other/.git/objects/pack/multi-pack-index

but also you seem to be touching areas that delete files. Could we 'touch' some of those and then see them get deleted?

Thanks, -Stolee

Previous: Johannes BergNext: Johannes Berg
Message 2 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.