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

[RFC] GIT_WORK_TREE

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Jun 3, 2007, 14:44 UTC
Message-ID
<20070603144401.GA9518@moooo.ath.cx>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 6 quoted lines
> I think it's a valid use case. Anyone remember why Matthias' patchset
> was dropped?
> It was last mentioned in
> http://article.gmane.org/gmane.comp.version-control.git/43041
> 
> Junio, Matthias? May I help?

Thanks for reminding me, I just did not finish the patch and then there was an exam which took all my time. But I took another look at it and made a new series, including the missing test cases. If you want to help please test it, check the source for errors, make comments etc.

This series introduces the GIT_WORK_TREE environment variable (and core.worktree config option) to specify the working tree that should be used with the repository (not for repositories found as .git directory). This allows to separate the repository and working tree.

Example use cases:
- you don't want to put the repository in the checkout (e.g. the
  checkout is publicly available but the history shouldn't)
- you want to track a read-only directory with git (e.g. track
  configuration files as normal user that are modified by other people
  or by yourself as superuser)
- there is a directory many people are working in and you can track
  the changes made by yourself and others without placing the .git
  directory in the directory
- checkout multiple repositories into the same directory
- see the mail form nguyen (Message-ID:
  <fcaeb9bf0705300742u22b54c78vccbc037fb553141f@mail.gmail.com>)

The patches are also available from git://igit.ath.cx/~matled/git in branch worktree (I might change this branch later) or as tag worktree1.

[PATCH] rev-parse: document --is-inside-git-dir [PATCH] rev-parse: introduce --is-bare-repository [PATCH] test git rev-parse [PATCH] introduce GIT_WORK_TREE to specify the work tree [PATCH] use new semantics of is_bare/inside_git_dir/inside_work_tree [PATCH] extend rev-parse test for --is-inside-work-tree [PATCH] test GIT_WORK_TREE

There are also a few things which are not addressed in this series:
- The documentation needs updates on what bare means.
- is_bare_repository should ignore trailing slashes when guessing if
  the repository is bare (/path/to/.git is not bare, /path/to/.git/ is
  bare if core.bare is unspecified).  Perhaps we can also set GIT_DIR
  to the path returned by getcwd which would solve this too.
- Aliases using --git-dir and/or --work-tree cause problems (also
  before this patch).  git should probably exec itself if an alias
  uses --git-dir or --work-tree.
- Calls to git_config(git_default_config) can be removed in many
  places because setup_git_directory_gently always reads the
  configuration.
- git init could set core.worktree if GIT_WORK_TREE is set.
Next: Matthias Lederhofer
Message 1 of 22 in “[RFC] GIT_WORK_TREE”
  1. Matthias LederhoferJun 3, 2007
  2. 1/7 rev-parse: document --is-inside-git-dirMatthias Lederhofer, Jun 3, 2007
  3. 2/7 rev-parse: introduce --is-bare-repositoryMatthias Lederhofer, Jun 3, 2007
  4. 3/7 test git rev-parseMatthias Lederhofer, Jun 3, 2007
  5. 3/7 test git rev-parseMatthias Lederhofer, Jun 6, 2007
  6. 4/7 introduce GIT_WORK_TREE to specify the work treeMatthias Lederhofer, Jun 3, 2007
  7. Junio C HamanoJun 5, 2007
  8. filter-branch: always export GIT_DIR if it is setMatthias Lederhofer, Jun 5, 2007
  9. Johannes SchindelinJun 5, 2007
  10. Junio C HamanoJun 5, 2007
  11. filter-branch: always export GIT_DIR if it is setMatthias Lederhofer, Jun 6, 2007
  12. 4/7 introduce GIT_WORK_TREE to specify the work treeMatthias Lederhofer, Jun 6, 2007
  13. Matthias LederhoferJun 3, 2007
  14. Matthias LederhoferJun 3, 2007
  15. 6/7 extend rev-parse test for --is-inside-work-treeMatthias Lederhofer, Jun 3, 2007
  16. 6/7 extend rev-parse test for --is-inside-work-treeMatthias Lederhofer, Jun 6, 2007
  17. 7/7 test GIT_WORK_TREEMatthias Lederhofer, Jun 3, 2007
  18. 7/7 test GIT_WORK_TREEMatthias Lederhofer, Jun 6, 2007
  19. SergioJun 3, 2007
  20. Matthias LederhoferJun 3, 2007
  21. SergioJun 3, 2007
  22. setup_git_directory: fix segfault if repository is found in cwdMatthias Lederhofer, Jun 6, 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.