All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2] multi-pack-index: fix *.rev cleanups with --object-dir
Date: Mon, 23 Aug 2021 12:06:14 -0400	[thread overview]
Message-ID: <YSPHdofrDOQk3xmy@coredump.intra.peff.net> (raw)
In-Reply-To: <20210823094049.44136-1-johannes@sipsolutions.net>

On Mon, Aug 23, 2021 at 11:40:49AM +0200, Johannes Berg wrote:

> If using --object-dir to point into a repo while the current
> working dir is outside, such as
> 
>   git init /repo
>   git -C /repo ... # add some objects
>   cd /non-repo
>   git multi-pack-index --object-dir /repo/.git/objects/ write
> 
> the binary 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 to clean up the *.rev files,
> this avoids the crash and cleans up the *.rev files for the
> now rewritten multi-pack-index properly.

I'm not entirely convinced that writing a midx when not "inside" a repo
is something that we want to support. But if we do, then...

> Due to running inside git's tree, even with TEST_NO_CREATE_REPO=t
> I cannot reproduce the segfault in a test without the "cd /", so
> I've kept that. Yes, the test caught in that case that the *.rev
> file wasn't cleaned up (due to being initialized to the wrong git
> repo [git's] and cleaning up there!), but I wanted to test the
> segfault too.

...there's a helper in the test suite for doing this kind of "not in a
repo" test:

diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index 3b6331f641..3981bf96d0 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -211,11 +211,8 @@ test_expect_success 'multi-pack-index *.rev cleanup with --object-dir' '
 	) &&
 	rev="objdir-test-repo/$objdir/pack/multi-pack-index-abcdef123456.rev" &&
 	touch $rev &&
-	(
-		base="$(pwd)" &&
-		cd / && # run outside any git repo, including git itself
-		git multi-pack-index --object-dir="$base/objdir-test-repo/$objdir" write
-	) &&
+	nongit git multi-pack-index \
+		--object-dir="$PWD/objdir-test-repo/$objdir" write &&
 	test_path_is_file objdir-test-repo/$objdir/pack/multi-pack-index &&
 	test_path_is_missing $rev
 '

-Peff

  reply	other threads:[~2021-08-23 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  9:40 [PATCH v2] multi-pack-index: fix *.rev cleanups with --object-dir Johannes Berg
2021-08-23 16:06 ` Jeff King [this message]
2021-08-23 17:05   ` Johannes Berg
2021-08-23 17:09     ` Taylor Blau
2021-08-23 17:56       ` Jeff King
2021-08-23 17:58       ` Junio C Hamano
2021-08-23 18:00       ` Derrick Stolee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSPHdofrDOQk3xmy@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.