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

[PATCH] Documentation: always respect core.worktree if set

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 28, 2009, 05:55 UTC
Message-ID
<1261979704-30074-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<fcaeb9bf0912272141j1def76e7v6f581636188e65f0@mail.gmail.com>

In the beginning, there was GIT_DIR environment variable. We had a very simple semantics:

 - When there is no GIT_DIR environment variable:
   - if "." is a "git directory", i.e. it has the set of git things like
     refs/, objects/ and HEAD, then you are working in a bare repository.
   - if ./.git exists and it is a "git directory", then "." is the top of
     the work tree;
   - otherwise, try the parent directory of "." for the second rule
     repeatedly to find the git directory and the top of the work tree.
 - When there is GIT_DIR environment variable:
   - $GIT_DIR is (and must be) the "git directory" and "." is the top of
     the work tree.

People wanted to have a work tree that is at a location totally unrelated to where the "git directory" and setting $GIT_DIR at runtime was the only way to do so, but that restricted them to work only at the top of the work tree. $GIT_WORK_TREE was invented as a way to say "this is the top of the work tree". So that people can do something like:

    $ GIT_DIR=/srv/git/proj.git GIT_WORK_TREE=/scratch/proj
    $ export GIT_DIR GIT_WORK_TREE
    $ cd $GIT_WORK_TREE/Documentation
    $ edit; git diff; git commit -a; ...

Because the facility was meant to allow separation of "git directory" and its associated work tree, and not meant to allow more than one work trees sharing the same "git directory" (which does not make any sense, as there is only one index in "git directory" that describes the state of the work tree), it was an unnecessary nuisanse that you had to set two environment variables. core.worktree was invented---by recording the location of the work tree in the config file in the "git directory", the above can be made into this:

    $ GIT_DIR=/srv/git/proj.git
    $ cd /scratch/proj/Documentation
    $ edit; git diff; git commit -a; ...

According to the current documentation, if GIT_DIR is not set, core.worktree is not respected, and the parent directory of the "git directory" may be used as worktree. This case, unless core.worktree matches the parent directory of the "git directory" in question, seems a misconfiguration and nothing else. So remove this part of the documentation.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Junio may find the description highly familiar :) only slightly modified
 at the end
 Documentation/config.txt |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 7d10a21..4b3d568 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -297,9 +297,7 @@ false), while all other repositories are assumed to be bare (bare
 = true).
 
 core.worktree::
-	Set the path to the working tree.  The value will not be
-	used in combination with repositories found automatically in
-	a .git directory (i.e. $GIT_DIR is not set).
+	Set the path to the working tree.
 	This can be overridden by the GIT_WORK_TREE environment
 	variable and the '--work-tree' command line option. It can be
 	a absolute path or relative path to the directory specified by
-- 
1.6.5.2.216.g9c1ec
Previous: Nguyen Thai Ngoc DuyNext: Junio C Hamano
Message 7 of 11 in “core.worktree bug”
  1. Robin RosenbergDec 7, 2009
  2. Nguyen Thai Ngoc DuyDec 15, 2009
  3. Fix core.worktree being used when GIT_DIR is not setNguyễn Thái Ngọc Duy, Dec 27, 2009
  4. Junio C HamanoDec 27, 2009
  5. Robin RosenbergDec 28, 2009
  6. Nguyen Thai Ngoc DuyDec 28, 2009
  7. Documentation: always respect core.worktree if setNguyễn Thái Ngọc Duy, Dec 28, 2009
  8. Junio C HamanoDec 28, 2009
  9. Documentation: always respect core.worktree if setNguyễn Thái Ngọc Duy, Dec 29, 2009
  10. Junio C HamanoDec 29, 2009
  11. Robin RosenbergDec 29, 2009

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.