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

[PATCH 1/3] receive-pack: drop tmp_objdir_env from run_update_hook

From
Jeff King <peff@peff.net>
Date
Apr 10, 2017, 22:13 UTC
Message-ID
<20170410221322.perffycei6z6ahqc@sigill.intra.peff.net>
In-Reply-To
<20170410221058.2ao64wedg2pa6uc2@sigill.intra.peff.net>

Since 722ff7f87 (receive-pack: quarantine objects until pre-receive accepts, 2016-10-03), we have to feed the pre-receive hook the tmp_objdir environment, so that git programs run from the hook know where to find the objects.

That commit modified run_update_hook() to do the same, but there it is a noop. By the time we get to the update hooks, we have already migrated the objects from quarantine, and so tmp_objdir_env() will always return NULL. We can drop this useless call.

Note that the ordering here and the lack of support for the update hook is intentional. The update hook calls are interspersed with actual ref updates, and we must migrate the objects before any refs are updated (since otherwise those refs would appear broken to outside processes). So the only other options are:

  - remain in quarantine for the _first_ ref, but not the
    others. This is sufficiently confusing that it can be
    rejected outright.
  - run all the individual update hooks first, then migrate,
    then update all the refs. But this changes the repository
    state that the update hooks see (i.e., whether or not
    refs from the same push are updated yet or not).

So the functionality is fine and remains unchanged with this patch; we're just cleaning up a useless and confusing line of code.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/receive-pack.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index aca9c33d8..b4469b3cc 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -772,7 +772,6 @@ static int run_update_hook(struct command *cmd)
 	proc.stdout_to_stderr = 1;
 	proc.err = use_sideband ? -1 : 0;
 	proc.argv = argv;
-	proc.env = tmp_objdir_env(tmp_objdir);
 
 	code = start_command(&proc);
 	if (code)
-- 
2.12.2.952.g759391acc
Previous: Jeff KingNext: Jeff King
Message 2 of 5 in “quarantine-push loose ends”
  1. 0/3 quarantine-push loose endsJeff King, Apr 10, 2017
  2. 1/3 receive-pack: drop tmp_objdir_env from run_update_hookJeff King, Apr 10, 2017
  3. 2/3 receive-pack: document user-visible quarantine effectsJeff King, Apr 10, 2017
  4. 3/3 refs: reject ref updates while GIT_QUARANTINE_PATH is setJeff King, Apr 10, 2017
  5. Ævar Arnfjörð BjarmasonApr 10, 2017

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.