Subject: Teach git-fetch(1) to use a quarantine directory

From: Toon Claes <[email-masked]>
Date: Mon, 17 Jul 2023 12:48:17 +0200

Hi,

I've been looking into making git-fetch(1) to use a quarantine
directory, but I'm a bit stuck on direction.

I took git-receive-pack(1) as an example how it uses a quarantine
directory. It seems it sets the environment variables
$GIT_OBJECT_DIRECTORY and $GIT_ALTERNATE_OBJECT_DIRECTORIES so the real
object db is used as an alternative, and a temporary is set as the
default. Then a sub-process is spawned to uses these. In case of
git-receive-pack(1), it calls git-unpack-objects(1).

At the moment git-fetch(1) does not spawn any similar subprocess, so if
we want to take the same approach to use the quarantine, we'll need to
split up that command.

But then we run into another problem as well. git-fetch(1) updates
references, and that is something that's not allowed when using a tmp
object directory.

As far as I can tell from the code, fetching packs and updating refs is
heavily intertwined, so I'm not sure this approach is the best way
forward. So a few questions:

1) Does it even make sense to make use git-fetch(1) use a quarantine
   directory?
2) When making git-fetch(1) use a quarantine directory, what is the
   recommended way to achieve this? Is this by calling a subprocess?
   Maybe git-fetch-pack(1)?

--
Toon