{"thread":{"id":"21887","subject":"core.worktree bug","startedAt":"2009-12-07T10:15:47Z","lastAt":"2009-12-29T17:05:55Z","messageCount":11,"participants":["Robin Rosenberg","Nguyen Thai Ngoc Duy","Nguyễn Thái Ngọc Duy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129399","messageId":"200912071115.48085.robin.rosenberg.lists@dewire.com","threadId":"21887","inReplyTo":null,"subject":"core.worktree bug","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-12-07T10:15:47Z","receivedAt":"2009-12-07T10:15:47Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"\nAccording to git-config(1) \n\n       core.worktree\n           Set the path to the working tree. The value will not be used in combination with repositories found automatically in a\n           .git directory (i.e. $GIT_DIR is not set). This can be overridden by the GIT_WORK_TREE environment variable and the\n           --work-tree command line option. It can be a absolute path or relative path to the directory specified by --git-dir or\n           GIT_DIR. Note: If --git-dir or GIT_DIR are specified but none of --work-tree, GIT_WORK_TREE and core.worktree is\n           specified, the current working directory is regarded as the top directory of your working tree.\n\nthis setting is not used if GIT_DIR is set. But when I try it out \n\n$ mkdir r1\n$ mkdir r2\n$ cd r2\n$ git init\nInitialized empty Git repository in /home/me/tmp/r2/.git/\n$ date >f\n$ git add f\n$ git commit -m \"f\"\n f\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 f\n$ git status\n# On branch master\nnothing to commit (working directory clean)\n\n=> Nothing interesting here. It comes here:\n\n$ git config core.worktree $(cd ../r1;pwd)\n$ git status\n# On branch master\n# Changed but not updated:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#       deleted:    f\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n=> Seems the config is actually honored even though GIT_DIR is not set.\n\nBisect tells me 4f38f6b5bafb1f7f85c7b54d0bb0a0e977cd947c broke it. My main point is that I am\nimplementing this in JGit so I want the same behaviour. Question: Should we try to fix this\nin git so it matches the documentation or fix the documentation to match behaviour.\n\nThe breakage appeared over a year ago and no one has complained.\n\n-- robin\n\nMy bisection script:\n\n#!/bin/bash\n\ntest_description=\"CEILING\"\n\n. ./test-lib.sh\n\ntest_expect_success \\\n    \"ceiling\" \\\n    \"\n     rm -rf r1 r2 &&\n     mkdir r1 r2 &&\n     (cd r2 &&\n     git init &&\n     date >f &&\n     git add f &&\necho ADD &&\n     git commit -m f &&\necho COMMIT &&\n     git diff --exit-code f && \necho DIFF &&\n     git config core.worktree \\$(cd ../r1/..;pwd) &&\necho CONFIG &&\n     (unset GIT_DIR;git diff --exit-code -- f) &&\necho DIFF\n     )\n     \"\n\ntest_don\n"},{"id":"129949","messageId":"20091215163042.GA14810@do","threadId":"21887","inReplyTo":"200912071115.48085.robin.rosenberg.lists@dewire.com","subject":"Re: core.worktree bug","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-12-15T16:30:42Z","receivedAt":"2009-12-15T16:30:42Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Dec 07, 2009 at 11:15:47AM +0100, Robin Rosenberg wrote:\n> $ git config core.worktree $(cd ../r1;pwd)\n> $ git status\n> # On branch master\n> # Changed but not updated:\n> #   (use \"git add/rm <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> #       deleted:    f\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> \n> => Seems the config is actually honored even though GIT_DIR is not set.\n> \n> Bisect tells me 4f38f6b5bafb1f7f85c7b54d0bb0a0e977cd947c broke it. My main point is that I am\n\nYou should have CCed me.\n\n> implementing this in JGit so I want the same behaviour. Question: Should we try to fix this\n> in git so it matches the documentation or fix the documentation to match behaviour.\n> \n> The breakage appeared over a year ago and no one has complained.\n\nThis is, I think, due to the shared use of git_work_tree_cfg. When\nsetup_git_directory_gently() comes close to the end, work_tree has\nbeen detected and set. Then check_repository_format_gently() is\ncalled to make sure the repository is valid. Among the checks are\ncore.worktree check, which overrides the previously-set git_work_tree_cfg.\n\nThis might be the fix, or a start of new breakages. I'll need to look\nat this again and make a proper patch message with tests if it's\nreally correct.\n\ndiff --git a/setup.c b/setup.c\nindex f67250b..1385edb 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -280,6 +280,18 @@ const char *read_gitfile_gently(const char *path)\n \treturn path;\n }\n \n+static int check_repository_work_tree(const char *var, const char *value, void *cb)\n+{\n+\tif (strcmp(var, \"core.worktree\") == 0) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tfree(git_work_tree_cfg);\n+\t\tgit_work_tree_cfg = xstrdup(value);\n+\t\tinside_work_tree = -1;\n+\t}\n+\treturn 0;\n+}\n+\n /*\n  * We cannot decide in this function whether we are in the work tree or\n  * not, since the config can only be read _after_ this function was called.\n@@ -317,6 +329,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\tif (!work_tree_env) {\n \t\t\t\tretval = set_work_tree(gitdirenv);\n \t\t\t\t/* config may override worktree */\n+\t\t\t\tgit_config(check_repository_work_tree, NULL);\n \t\t\t\tif (check_repository_format_gently(nongit_ok))\n \t\t\t\t\treturn NULL;\n \t\t\t\treturn retval;\n@@ -394,6 +407,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\tdie_errno(\"Cannot change to '%s/..'\", cwd);\n \t}\n \n+\tgit_config(check_repository_work_tree, NULL);\n \tinside_git_dir = 0;\n \tif (!work_tree_env)\n \t\tinside_work_tree = 1;\n@@ -471,12 +485,6 @@ int check_repository_format_version(const char *var, const char *value, void *cb\n \t\tis_bare_repository_cfg = git_config_bool(var, value);\n \t\tif (is_bare_repository_cfg == 1)\n \t\t\tinside_work_tree = -1;\n-\t} else if (strcmp(var, \"core.worktree\") == 0) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tfree(git_work_tree_cfg);\n-\t\tgit_work_tree_cfg = xstrdup(value);\n-\t\tinside_work_tree = -1;\n \t}\n \treturn 0;\n }\n\n\n\n-- \nDuy\n"},{"id":"130362","messageId":"1261920513-25189-1-git-send-email-pclouds@gmail.com","threadId":"21887","inReplyTo":"200912071115.48085.robin.rosenberg.lists@dewire.com","subject":"[PATCH] Fix core.worktree being used when GIT_DIR is not set","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-12-27T13:28:33Z","receivedAt":"2009-12-27T13:28:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"According to config.txt:\n> core.worktree::\n>         Set the path to the working tree.  The value will not be\n>         used in combination with repositories found automatically in\n>         a .git directory (i.e. $GIT_DIR is not set).\n\nThis behavior was changed after e90fdc3 (Clean up work-tree handling -\n2007-08-01) and 9459aa7 (Do check_repository_format() early (re-fix) -\n2007-12-05). If core.worktree is set, even if git_dir automatically\nfound (and git_work_tree_cfg set), git_work_tree_cfg will be reset to\ncore.worktree. This makes core.worktree effective even if GIT_DIR is\nnot set, in contrast to config.txt.\n\nThis patch makes sure it only checks for core.worktree if GIT_DIR is set.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n setup.c             |   19 +++++++++++++------\n t/t1501-worktree.sh |    4 ++++\n 2 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 2cf0f19..35b7915 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -283,6 +283,18 @@ const char *read_gitfile_gently(const char *path)\n \treturn path;\n }\n \n+static int check_repository_work_tree(const char *var, const char *value, void *cb)\n+{\n+\tif (strcmp(var, \"core.worktree\") == 0) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tfree(git_work_tree_cfg);\n+\t\tgit_work_tree_cfg = xstrdup(value);\n+\t\tinside_work_tree = -1;\n+\t}\n+\treturn 0;\n+}\n+\n /*\n  * We cannot decide in this function whether we are in the work tree or\n  * not, since the config can only be read _after_ this function was called.\n@@ -320,6 +332,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\tif (!work_tree_env) {\n \t\t\t\tretval = set_work_tree(gitdirenv);\n \t\t\t\t/* config may override worktree */\n+\t\t\t\tgit_config(check_repository_work_tree, NULL);\n \t\t\t\tif (check_repository_format_gently(nongit_ok))\n \t\t\t\t\treturn NULL;\n \t\t\t\treturn retval;\n@@ -474,12 +487,6 @@ int check_repository_format_version(const char *var, const char *value, void *cb\n \t\tis_bare_repository_cfg = git_config_bool(var, value);\n \t\tif (is_bare_repository_cfg == 1)\n \t\t\tinside_work_tree = -1;\n-\t} else if (strcmp(var, \"core.worktree\") == 0) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tfree(git_work_tree_cfg);\n-\t\tgit_work_tree_cfg = xstrdup(value);\n-\t\tinside_work_tree = -1;\n \t}\n \treturn 0;\n }\ndiff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh\nindex 74e6443..9756f35 100755\n--- a/t/t1501-worktree.sh\n+++ b/t/t1501-worktree.sh\n@@ -30,6 +30,10 @@ test_rev_parse() {\n \n EMPTY_TREE=$(git write-tree)\n mkdir -p work/sub/dir || exit 1\n+\n+git config core.worktree work\n+test_rev_parse 'core.worktree without GIT_DIR' false false true ''\n+\n mv .git repo.git || exit 1\n \n say \"core.worktree = relative path\"\n-- \n1.6.5.2.216.g9c1ec\n"},{"id":"130370","messageId":"7viqbsw2vn.fsf@alter.siamese.dyndns.org","threadId":"21887","inReplyTo":"1261920513-25189-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] Fix core.worktree being used when GIT_DIR is not set","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-27T20:58:20Z","receivedAt":"2009-12-27T20:58:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> According to config.txt:\n>> core.worktree::\n>>         Set the path to the working tree.  The value will not be\n>>         used in combination with repositories found automatically in\n>>         a .git directory (i.e. $GIT_DIR is not set).\n>\n> This behavior was changed after e90fdc3 (Clean up work-tree handling -\n> 2007-08-01) and 9459aa7 (Do check_repository_format() early (re-fix) -\n> 2007-12-05). If core.worktree is set, even if git_dir automatically\n> found (and git_work_tree_cfg set), git_work_tree_cfg will be reset to\n> core.worktree. This makes core.worktree effective even if GIT_DIR is\n> not set, in contrast to config.txt.\n>\n> This patch makes sure it only checks for core.worktree if GIT_DIR is set.\n\nThe work-tree area got too complicated over time for a small Panda brain\nto grasp, so let me think aloud here.\n\nThe command line option --git-dir= has the same impact on the semantics as\nthe $GIT_DIR environment variable has.  The only difference is that the\noption has higher precedence over environment.  Therefore, I won't talk\nabout the command line options in the following description.\n\nIn the beginning, there was GIT_DIR environment variable.  We had a very\nsimple semantics:\n\n - When there is no GIT_DIR environment variable:\n\n   - if \".\" is a \"git directory\", i.e. it has the set of git things like\n     refs/, objects/ and HEAD, then you are working in a bare repository.\n\n   - if ./.git exists and it is a \"git directory\", then \".\" is the top of\n     the work tree;\n\n   - otherwise, try the parent directory of \".\" for the second rule\n     repeatedly to find the git directory and the top of the work tree.\n\n - When there is GIT_DIR environment variable:\n\n   - $GIT_DIR is (and must be) the \"git directory\" and \".\" is the top of\n     the work tree.\n\nPeople wanted to have a work tree that is at a location totally unrelated\nto where the \"git directory\" and setting $GIT_DIR at runtime was the only\nway to do so, but that restricted them to work only at the top of the work\ntree.  $GIT_WORK_TREE was invented as a way to say \"this is the top of the\nwork tree\".  So that people can do something like:\n\n    $ GIT_DIR=/srv/git/proj.git GIT_WORK_TREE=/scratch/proj\n    $ export GIT_DIR GIT_WORK_TREE\n    $ cd $GIT_WORK_TREE/Documentation\n    $ edit; git diff; git commit -a; ...\n\nBecause the facility was meant to allow separation of \"git directory\" and\nits associated work tree, and not meant to allow more than one work trees\nsharing the same \"git directory\" (which does not make any sense, as there\nis only one index in \"git directory\" that describes the state of the work\ntree), it was an unnecessary nuisanse that you had to set two environment\nvariables.  core.worktree was invented---by recording the location of the\nwork tree in the config file in the \"git directory\", the above can be made\ninto this:\n\n    $ GIT_DIR=/srv/git/proj.git\n    $ cd /scratch/proj/Documentation\n    $ edit; git diff; git commit -a; ...\n\nGiven these background, I am not sure the \"fix\" is addressing the right\nissue.  What does it mean to have \"core.worktree\" in a configuration file,\nbut that configuration file was found in a \"git directory\" that was found\nthorough the repository discovery process due to lack of $GIT_DIR?  There\nare only two cases I can see:\n\n - The user is in the \"git directory\" itself, which is bare (iow,\n   /srv/git/proj.git in the above example).  This is not the case the\n   documentation snippet you quoted is about, and I don't think your patch\n   changes (nor should change) the behaviour for;\n\n - The \"git directory\" is a \".git/\" subdirectory of some work tree, and\n   the value of core.worktree may or may not match that work tree.  This\n   is the case the documentation talks about, and your patch addresses.\n\nFor the former case, while I don't see much point, we do seem to support\nthis use case (continuing the example scenario):\n\n    $ unset GIT_DIR GIT_WORK_TREE\n    $ cd /srv/git/proj.git\n    $ git checkout -b newbranch master\n\nWe find that \".\" is our \"git directory\", and through its config file, we\nknow core.worktree points at /scratch/proj/, and the checkout updates\nfiles over there, not in /srv/git/proj.git/.  While it is not obvious why\nanybody finds this useful to me, I think the behaviour makes _some_ sense,\nand I don't think your patch breaks it by changing the behaviour for this\ncase [*1*].\n\nThe latter, unless core.worktree matches the parent directory of the \"git\ndirectory\" in question, seems to me a misconfiguration and nothing else.\nShouldn't it be diagnosed as an error, instead of matching the\ndocumentation to the letter?\n\n[Footnote]\n\n*1* I said \"makes _some_ sense\" for a reason.  While operations like\nswitching branches that is inherently whole-tree makes sense, it is\ntotally unclear what operations that work relative to the work tree,\ni.e. \"git add\", in such a set-up.\n"},{"id":"130378","messageId":"200912280108.10113.robin.rosenberg@dewire.com","threadId":"21887","inReplyTo":"7viqbsw2vn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Fix core.worktree being used when GIT_DIR is not set","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2009-12-28T00:08:09Z","receivedAt":"2009-12-28T00:08:09Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndagen den 27 december 2009 21.58.20 skrev  Junio C Hamano:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n> > According to config.txt:\n> >> core.worktree::\n> >>         Set the path to the working tree.  The value will not be\n> >>         used in combination with repositories found automatically in\n> >>         a .git directory (i.e. $GIT_DIR is not set).\n> >\n> > This behavior was changed after e90fdc3 (Clean up work-tree handling -\n> > 2007-08-01) and 9459aa7 (Do check_repository_format() early (re-fix) -\n> > 2007-12-05). If core.worktree is set, even if git_dir automatically\n> > found (and git_work_tree_cfg set), git_work_tree_cfg will be reset to\n> > core.worktree. This makes core.worktree effective even if GIT_DIR is\n> > not set, in contrast to config.txt.\n> >\n> > This patch makes sure it only checks for core.worktree if GIT_DIR is set.\n\n...\n\n> \n> Given these background, I am not sure the \"fix\" is addressing the right\n> issue.  What does it mean to have \"core.worktree\" in a configuration file,\n> but that configuration file was found in a \"git directory\" that was found\n> thorough the repository discovery process due to lack of $GIT_DIR?  There\n> are only two cases I can see:\n\nI'm inclined towards fixing the docs. Overriding a config setting in non-\nintuitive and nobody has complained.\n\n-- robin\n"},{"id":"130387","messageId":"fcaeb9bf0912272141j1def76e7v6f581636188e65f0@mail.gmail.com","threadId":"21887","inReplyTo":"7viqbsw2vn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Fix core.worktree being used when GIT_DIR is not set","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-12-28T05:41:24Z","receivedAt":"2009-12-28T05:41:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 12/28/09, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>  > According to config.txt:\n>  >> core.worktree::\n>  >>         Set the path to the working tree.  The value will not be\n>  >>         used in combination with repositories found automatically in\n>  >>         a .git directory (i.e. $GIT_DIR is not set).\n>  >\n>  > This behavior was changed after e90fdc3 (Clean up work-tree handling -\n>  > 2007-08-01) and 9459aa7 (Do check_repository_format() early (re-fix) -\n>  > 2007-12-05). If core.worktree is set, even if git_dir automatically\n>  > found (and git_work_tree_cfg set), git_work_tree_cfg will be reset to\n>  > core.worktree. This makes core.worktree effective even if GIT_DIR is\n>  > not set, in contrast to config.txt.\n>  >\n>  > This patch makes sure it only checks for core.worktree if GIT_DIR is set.\n>\n>\n> The work-tree area got too complicated over time for a small Panda brain\n>  to grasp, so let me think aloud here.\n>\n>  ...\n>\n>  Given these background, I am not sure the \"fix\" is addressing the right\n>  issue.  What does it mean to have \"core.worktree\" in a configuration file,\n>  but that configuration file was found in a \"git directory\" that was found\n>  thorough the repository discovery process due to lack of $GIT_DIR?  There\n>  are only two cases I can see:\n>\n>   - The user is in the \"git directory\" itself, which is bare (iow,\n>    /srv/git/proj.git in the above example).  This is not the case the\n>    documentation snippet you quoted is about, and I don't think your patch\n>    changes (nor should change) the behaviour for;\n>\n>   - The \"git directory\" is a \".git/\" subdirectory of some work tree, and\n>    the value of core.worktree may or may not match that work tree.  This\n>    is the case the documentation talks about, and your patch addresses.\n>\n>  For the former case, while I don't see much point, we do seem to support\n>  this use case (continuing the example scenario):\n>\n>     $ unset GIT_DIR GIT_WORK_TREE\n>     $ cd /srv/git/proj.git\n>     $ git checkout -b newbranch master\n>\n>  We find that \".\" is our \"git directory\", and through its config file, we\n>  know core.worktree points at /scratch/proj/, and the checkout updates\n>  files over there, not in /srv/git/proj.git/.  While it is not obvious why\n>  anybody finds this useful to me, I think the behaviour makes _some_ sense,\n>  and I don't think your patch breaks it by changing the behaviour for this\n>  case [*1*].\n>\n>  The latter, unless core.worktree matches the parent directory of the \"git\n>  directory\" in question, seems to me a misconfiguration and nothing else.\n>  Shouldn't it be diagnosed as an error, instead of matching the\n>  documentation to the letter?\n\nI had not read that part of the documentation until Robin pointed out\nand always thought core.worktree was in effect if set. I thought the\nauthor intention was not to let core.worktree get in the way if not\nrequested, but given that the worktree is moved to somewhere else\nalready, that does not make sense as it could use parent directory of\nthe \"git directory\" as worktree (unless core.worktree matches the\nparent directory as you said). Probably best fixing documentation.\n-- \nDuy\n"},{"id":"130388","messageId":"1261979704-30074-1-git-send-email-pclouds@gmail.com","threadId":"21887","inReplyTo":"fcaeb9bf0912272141j1def76e7v6f581636188e65f0@mail.gmail.com","subject":"[PATCH] Documentation: always respect core.worktree if set","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-12-28T05:55:04Z","receivedAt":"2009-12-28T05:55:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"In the beginning, there was GIT_DIR environment variable.  We had a very\nsimple semantics:\n\n - When there is no GIT_DIR environment variable:\n\n   - if \".\" is a \"git directory\", i.e. it has the set of git things like\n     refs/, objects/ and HEAD, then you are working in a bare repository.\n\n   - if ./.git exists and it is a \"git directory\", then \".\" is the top of\n     the work tree;\n\n   - otherwise, try the parent directory of \".\" for the second rule\n     repeatedly to find the git directory and the top of the work tree.\n\n - When there is GIT_DIR environment variable:\n\n   - $GIT_DIR is (and must be) the \"git directory\" and \".\" is the top of\n     the work tree.\n\nPeople wanted to have a work tree that is at a location totally unrelated\nto where the \"git directory\" and setting $GIT_DIR at runtime was the only\nway to do so, but that restricted them to work only at the top of the work\ntree.  $GIT_WORK_TREE was invented as a way to say \"this is the top of the\nwork tree\".  So that people can do something like:\n\n    $ GIT_DIR=/srv/git/proj.git GIT_WORK_TREE=/scratch/proj\n    $ export GIT_DIR GIT_WORK_TREE\n    $ cd $GIT_WORK_TREE/Documentation\n    $ edit; git diff; git commit -a; ...\n\nBecause the facility was meant to allow separation of \"git directory\" and\nits associated work tree, and not meant to allow more than one work trees\nsharing the same \"git directory\" (which does not make any sense, as there\nis only one index in \"git directory\" that describes the state of the work\ntree), it was an unnecessary nuisanse that you had to set two environment\nvariables.  core.worktree was invented---by recording the location of the\nwork tree in the config file in the \"git directory\", the above can be made\ninto this:\n\n    $ GIT_DIR=/srv/git/proj.git\n    $ cd /scratch/proj/Documentation\n    $ edit; git diff; git commit -a; ...\n\nAccording to the current documentation, if GIT_DIR is not set,\ncore.worktree is not respected, and the parent directory of the \"git\ndirectory\" may be used as worktree. This case, unless core.worktree\nmatches the parent directory of the \"git directory\" in question, seems\na misconfiguration and nothing else. So remove this part of the\ndocumentation.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Junio may find the description highly familiar :) only slightly modified\n at the end\n\n Documentation/config.txt |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7d10a21..4b3d568 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -297,9 +297,7 @@ false), while all other repositories are assumed to be bare (bare\n = true).\n \n core.worktree::\n-\tSet the path to the working tree.  The value will not be\n-\tused in combination with repositories found automatically in\n-\ta .git directory (i.e. $GIT_DIR is not set).\n+\tSet the path to the working tree.\n \tThis can be overridden by the GIT_WORK_TREE environment\n \tvariable and the '--work-tree' command line option. It can be\n \ta absolute path or relative path to the directory specified by\n-- \n1.6.5.2.216.g9c1ec\n"},{"id":"130389","messageId":"7viqbrv4pa.fsf@alter.siamese.dyndns.org","threadId":"21887","inReplyTo":"1261979704-30074-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] Documentation: always respect core.worktree if set","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-28T09:16:33Z","receivedAt":"2009-12-28T09:16:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> In the beginning, there was GIT_DIR environment variable, with a very\n> simple semantics:\n> ...\n\n(Omitted an explanation of how GIT_DIR and core.worktree work together).\n\n> According to the current documentation, if GIT_DIR is not set,\n> core.worktree is not respected, and the parent directory of the \"git\n> directory\" may be used as worktree. This case, unless core.worktree\n> matches the parent directory of the \"git directory\" in question, seems\n> a misconfiguration and nothing else. So remove this part of the\n> documentation.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  Junio may find the description highly familiar :) only slightly modified\n>  at the end\n\nI found it familiar, but I didn't see how that earlier part leads to the\nconclusion in, or even gives a necessary background information for, the\nlast paragraph.  Perhaps you omitted something in the middle that was more\nrelevant?  If so, I would suggest omiting the earlier part, whose purpose\nwas to prepare readers for that middle part, as well.\n\nAnd I don't think the claim your last paragraph makes is consistent with\nwhat the patch does at all.\n\nRemoving the \"it will be ignored\" from the documentation is a good change\nonly in the sense that it makes the document closer to reality, but \"it is\na misconfiguration\" is not a good justification of the change.\n\nA documentation-only patch that can be justitifed by \"a misconfiguration\"\nclaim would probably read like this:\n\n\tThe value of core.worktree in a \".git/config\" is honored even when\n\tit differs from the directory that has the \".git\" directory as its\n\tsubdirectory.  This is likely to be a misconfiguration, so warn\n\tusers about it.  Also, drop the part of the documentation that\n\tincorrectly claimed that we ignore such a misconfigured value.\n\n\t---\n\n\tcore.worktree::\n                Set the path to the root of the work tree.  Note that this\n        \tis honored even when set in a configuration file in a\n        \t\".git\" subdirectory of a directory, and its value differs\n        \tfrom the latter directory (e.g. \"/path/to/.git/config\" has\n        \tcore.worktree set to \"/different/path\"), which is most\n        \tlikely a misconfiguration.  Running git commands in\n        \t\"/path/to\" directory will still use \"/different/path\" as\n        \tthe root of the work tree and can cause great confusion to\n        \tthe users.\n\n\nYour earlier patch took a different approach to the misconfiguration.  \"It\nis an error, so we silently _ignore_\".  It is a valid thing to say, but\nthe \"silently\" part is not friendly to the user and we would probably want\nto diagnose and warn.  That is what I originally meant.\n"},{"id":"130437","messageId":"1262072921-11280-1-git-send-email-pclouds@gmail.com","threadId":"21887","inReplyTo":"7viqbrv4pa.fsf@alter.siamese.dyndns.org","subject":"[PATCH] Documentation: always respect core.worktree if set","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-12-29T07:48:41Z","receivedAt":"2009-12-29T07:48:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The value of core.worktree in a \".git/config\" is honored even when it\ndiffers from the directory that has the \".git\" directory as its\nsubdirectory.  This is likely to be a misconfiguration, so warn users\nabout it.  Also, drop the part of the documentation that incorrectly\nclaimed that we ignore such a misconfigured value.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/config.txt |   23 +++++++++++++++--------\n 1 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 7d10a21..2eb9758 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -297,17 +297,24 @@ false), while all other repositories are assumed to be bare (bare\n = true).\n \n core.worktree::\n-\tSet the path to the working tree.  The value will not be\n-\tused in combination with repositories found automatically in\n-\ta .git directory (i.e. $GIT_DIR is not set).\n+\tSet the path to the root of the work tree.\n \tThis can be overridden by the GIT_WORK_TREE environment\n \tvariable and the '--work-tree' command line option. It can be\n-\ta absolute path or relative path to the directory specified by\n-\t--git-dir or GIT_DIR.\n-\tNote: If --git-dir or GIT_DIR are specified but none of\n+\tan absolute path or a relative path to the .git directory,\n+\teither specified by --git-dir or GIT_DIR, or automatically\n+\tdiscovered.\n+\tIf --git-dir or GIT_DIR are specified but none of\n \t--work-tree, GIT_WORK_TREE and core.worktree is specified,\n-\tthe current working directory is regarded as the top directory\n-\tof your working tree.\n+\tthe current working directory is regarded as the root of the\n+\twork tree.\n++\n+Note that this variable is honored even when set in a configuration\n+file in a \".git\" subdirectory of a directory, and its value differs\n+from the latter directory (e.g. \"/path/to/.git/config\" has\n+core.worktree set to \"/different/path\"), which is most likely a\n+misconfiguration.  Running git commands in \"/path/to\" directory will\n+still use \"/different/path\" as the root of the work tree and can cause\n+great confusion to the users.\n \n core.logAllRefUpdates::\n \tEnable the reflog. Updates to a ref <ref> is logged to the file\n-- \n1.6.5.2.216.g9c1ec\n"},{"id":"130467","messageId":"7v7hs5hg46.fsf@alter.siamese.dyndns.org","threadId":"21887","inReplyTo":"1262072921-11280-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] Documentation: always respect core.worktree if set","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-29T16:58:17Z","receivedAt":"2009-12-29T16:58:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; I'll take this \"match documentation to reality with caveats\" patch\nfor now, but I personally think we should revisit the issue someday.\n"},{"id":"130472","messageId":"200912291805.55272.robin.rosenberg@dewire.com","threadId":"21887","inReplyTo":"7v7hs5hg46.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Documentation: always respect core.worktree if set","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2009-12-29T17:05:55Z","receivedAt":"2009-12-29T17:05:55Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"tisdagen den 29 december 2009 17.58.17 skrev  Junio C Hamano:\n> Thanks; I'll take this \"match documentation to reality with caveats\" patch\n> for now, but I personally think we should revisit the issue someday.\n> \n\nI'm happy with this.\n\n-- robin\n"}]}