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

Re: Question regarding quarantine environments

From
Jeff King <peff@peff.net>
Date
Aug 2, 2018, 18:39 UTC
Message-ID
<20180802183924.GB23690@sigill.intra.peff.net>
In-Reply-To
<CALcD6sYfcaftciYU+2AHpzabyOS9ohRcZoE6LDuMyht+dxktHw@mail.gmail.com>
On Thu, Aug 02, 2018 at 12:58:52PM -0500, Liam Decker wrote:
Show 7 quoted lines
> I've been working on a git hook in golang recently. However, the library I
> was using did not support a possible quarantine directory, which I would
> use for my hook.
> 
> I have been trying to find out how git finds this incoming directory in the
> objects folder, as their code simply assumed it resided in
> .git/objects/<1st byte>/<last 19 bytes>

When you're running a hook inside the quarantine environment, then $GIT_OBJECT_DIRECTORY in the environment will be set to the quarantine directory, and $GIT_ALTERNATE_OBJECT_DIRECTORIES will point to the main repository object directory (possibly alongside other alternates, if there were any already set).

Any Git commands you run should therefore find objects from either location, but any writes would go to the quarantine (most notably, Git's own index-pack/unpack-objects processes, which is the point of the quarantine in the first place).

> The solution that I implemented was to check the objects directory for the
> object, and if it was not there, to look for a quarantine directory and try
> there. However, that feels fairly inefficient.

That's more or less what Git will do under the hood (though in the opposite order).

> For the curious, the library and solution I attempted are both here [5]

Just skimming, but it sounds like go-git does not support the GIT_OBJECT_DIRECTORY environment variable.

-Peff
Previous: Liam DeckerNext: Jonathan Nieder
Message 2 of 7 in “Question regarding quarantine environments”
  1. Liam DeckerAug 2, 2018
  2. Jeff KingAug 2, 2018
  3. Jonathan NiederAug 3, 2018
  4. Ævar Arnfjörð BjarmasonAug 3, 2018
  5. Jeff KingAug 3, 2018
  6. Ævar Arnfjörð BjarmasonAug 3, 2018
  7. Jeff KingAug 3, 2018

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.