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

Re: What's cooking in git.git (topics)

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Jun 28, 2007, 20:23 UTC
Message-ID
<20070628202321.GA13263@moooo.ath.cx>
In-Reply-To
<7vtzsurvo1.fsf@assigned-by-dhcp.pobox.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> I think the behaviour for receive-pack and the environment the
> hooks run in have been pretty well defined.  You start in the
> repository (the directory $GIT_DIR), GIT_DIR is set and points
> at it.
> 
> The issue is that the introduction of WORK_TREE enviornment and
> core.worktree mechanism might want to update the semantics.  For
> example, some people seem to run checkout (or perhaps "merge")
> to update the associated working tree.  Can they find out where
> the root of the working tree is (because they would want to
> chdir to it before saying "git checkout"), given the current
> environment receive-pack sets up for them?
>
> Earlier we said that people who use only GIT_DIR without
> GIT_WORK_TREE nor core.worktree should get exactly the same
> semantics with or without the WORK_TREE topic, so the above may
> not be an issue.

When GIT_WORK_TREE/core.worktree are not set the only difference with the patch series should be that cwd may be used as working tree in more cases than before.

I think these are the ways git-receive-pack is executed (in normal
setups):
 * local pushes: git_connect() unsets GIT_WORK_TREE.
 * ssh: the user might set GIT_WORK_TREE in his shell
   configuration, .ssh/environments, .ssh/authorized_keys etc.
   git-receive-pack is then executed with GIT_WORK_TREE set.
 * git-daemon: git-daemon with --enable=receive-pack allows pushing
   and does not unset GIT_WORK_TREE, so a git-daemon started with
   GIT_WORK_TREE exported will also have it exported when receive-pack
   is executed.

I think it makes sense to unset GIT_WORK_TREE when receive-pack is started. In the first case GIT_WORK_TREE is unset already and in the latter two cases I don't think we really need to support that GIT_WORK_TREE stays exported in the hooks, it could rather happen accidentally.

When doing more stuff in receive-pack old hooks might stop working break.

For example receive-pack could set up GIT_WORK_TREE with a sane
default value if a working tree can be found, i.e.
    $ export GIT_WORK_TREE=$(dirname $(pwd))
if the working tree is in the parent directory
    $ export GIT_WORK_TREE=$(git config core.worktree)
if core.worktree is set and otherwise GIT_WORK_TREE is not exported.
This way hooks can just use GIT_WORK_TREE for the working tree if
they don't need anything special.
Previous: Junio C HamanoNext: Junio C Hamano
Message 31 of 34 in “What's cooking in git.git (topics)”
  1. Junio C HamanoMay 13, 2007
  2. Julian PhillipsMay 13, 2007
  3. Junio C HamanoMay 13, 2007
  4. Julian PhillipsMay 14, 2007
  5. Daniel BarkalowMay 14, 2007
  6. Junio C HamanoMay 17, 2007
  7. Daniel BarkalowMay 17, 2007
  8. Junio C HamanoMay 17, 2007
  9. Daniel BarkalowMay 17, 2007
  10. Junio C HamanoMay 19, 2007
  11. Junio C HamanoMay 23, 2007
  12. Shawn O. PearceMay 24, 2007
  13. Junio C HamanoMay 29, 2007
  14. Junio C HamanoJun 2, 2007
  15. Johannes SchindelinJun 3, 2007
  16. Shawn O. PearceJun 3, 2007
  17. Nicolas PitreJun 3, 2007
  18. Dana HowJun 3, 2007
  19. Junio C HamanoJun 7, 2007
  20. Junio C HamanoJun 13, 2007
  21. Johannes SchindelinJun 13, 2007
  22. Linus TorvaldsJun 14, 2007
  23. Matthias LederhoferJun 18, 2007
  24. Junio C HamanoJun 21, 2007
  25. Linus TorvaldsJun 21, 2007
  26. Linus TorvaldsJun 21, 2007
  27. Junio C HamanoJun 25, 2007
  28. Jeffrey C. OllieJun 25, 2007
  29. Matthias LederhoferJun 26, 2007
  30. Junio C HamanoJun 27, 2007
  31. Matthias LederhoferJun 28, 2007
  32. Junio C HamanoJun 29, 2007
  33. Junio C HamanoJul 2, 2007
  34. Junio C HamanoJul 28, 2007

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.