{"thread":{"id":"23031","subject":"[PATCH] Add support for GIT_ONE_FILESYSTEM","startedAt":"2010-03-15T21:40:03Z","lastAt":"2010-03-16T05:56:25Z","messageCount":8,"participants":["Lars Damerow","Sverre Rabbelier","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"136884","messageId":"20100315214003.GB11157@pixar.com","threadId":"23031","inReplyTo":null,"subject":"[PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-15T21:40:03Z","receivedAt":"2010-03-15T21:40:03Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":"This patch makes git pay attention to the GIT_ONE_FILESYSTEM environment\nvariable. When that variable is set, git will stop searching for a\nGIT_DIR when it attempts to cross a filesystem boundary.\n\nWhen working in an environment with too many automount points to make\nmaintaining a GIT_CEILING_DIRECTORIES list enjoyable, GIT_ONE_FILESYSTEM\ngives the option of turning all such attempts off with one setting.\n\nSigned-off-by: Lars R. Damerow <lars@pixar.com>\n---\n Documentation/git.txt |    3 +++\n setup.c               |   11 +++++++++++\n 2 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 35c0c79..dbb590f 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -529,6 +529,9 @@ git so take care if using Cogito etc.\n \ta GIT_DIR set on the command line or in the environment.\n \t(Useful for excluding slow-loading network directories.)\n \n+'GIT_ONE_FILESYSTEM'::\n+\tStop at filesystem boundaries when looking for .git or objects.\n+\n git Commits\n ~~~~~~~~~~~\n 'GIT_AUTHOR_NAME'::\ndiff --git a/setup.c b/setup.c\nindex 5716d90..63dc52e 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -323,6 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \tconst char *gitdirenv;\n \tconst char *gitfile_dir;\n \tint len, offset, ceil_offset, root_len;\n+\tint current_device = 0;\n+\tstruct stat buf;\n \n \t/*\n \t * Let's assume that we are in a git repository.\n@@ -390,6 +392,9 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t *   etc.\n \t */\n \toffset = len = strlen(cwd);\n+\tif (stat(\".\", &buf))\n+\t\tdie_errno(\"failed to stat '.'\");\n+\tcurrent_device = buf.st_dev;\n \tfor (;;) {\n \t\tgitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);\n \t\tif (gitfile_dir) {\n@@ -422,6 +427,12 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\t}\n \t\t\tdie(\"Not a git repository (or any of the parent directories): %s\", DEFAULT_GIT_DIR_ENVIRONMENT);\n \t\t}\n+\t\tif (getenv(\"GIT_ONE_FILESYSTEM\") != NULL) {\n+\t\t\tif (stat(\"..\", &buf))\n+\t\t\t\tdie_errno(\"failed to stat '..'\");\n+\t\t\tif (buf.st_dev != current_device)\n+\t\t\t\tdie(\"refusing to cross filesystem boundary '%s/..'\", cwd);\n+\t\t}\n \t\tif (chdir(\"..\"))\n \t\t\tdie_errno(\"Cannot change to '%s/..'\", cwd);\n \t}\n-- \n1.6.5.2\n"},{"id":"136893","messageId":"fabb9a1e1003151616m4c0e9100g77170433f6a67912@mail.gmail.com","threadId":"23031","inReplyTo":"20100315214003.GB11157@pixar.com","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-03-15T23:16:19Z","receivedAt":"2010-03-15T23:16:19Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, Mar 15, 2010 at 22:40, Lars Damerow <lars@pixar.com> wrote:\n> +                       if (buf.st_dev != current_device)\n> +                               die(\"refusing to cross filesystem boundary '%s/..'\", cwd);\n\nGreat, that's going to tell the unfortunate user who runs into this a\nwhole lot of nothing. Shouldn't you at least tell them what git was\ntrying to do, how they can fix it if this is not the desired behavior,\netc. etc.?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"136901","messageId":"20100315233645.GG11157@pixar.com","threadId":"23031","inReplyTo":"fabb9a1e1003151616m4c0e9100g77170433f6a67912@mail.gmail.com","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-15T23:36:45Z","receivedAt":"2010-03-15T23:36:45Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":">From Sverre Rabbelier <srabbelier@gmail.com>, Tue, Mar 16, 2010 at 12:16:19AM +0100:\n> Heya,\n> \n> On Mon, Mar 15, 2010 at 22:40, Lars Damerow <lars@pixar.com> wrote:\n> > if (buf.st_dev != current_device)\n> >     die(\"refusing to cross filesystem boundary '%s/..'\", cwd);\n> \n> Great, that's going to tell the unfortunate user who runs into this a\n> whole lot of nothing. Shouldn't you at least tell them what git was\n> trying to do, how they can fix it if this is not the desired behavior,\n> etc. etc.?\n\nHi Sverre,\n\nYou're right, that's a badly-worded error. How about this?\n\n    Not a git repository (or any parent up to /path/to/mountpoint)\n    Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is set.\n\n-lars\n\n--\nlars r. damerow :: button pusher :: pixar animation studios\n\nScience Factoid:  The common cockroach shares 99.5 percent of its DNA code\n                  with e-mail spammers and telemarketers.\n"},{"id":"136914","messageId":"20100316023306.GA14253@coredump.intra.peff.net","threadId":"23031","inReplyTo":"20100315214003.GB11157@pixar.com","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-16T02:33:06Z","receivedAt":"2010-03-16T02:33:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 15, 2010 at 02:40:03PM -0700, Lars Damerow wrote:\n\n> +\t\tif (getenv(\"GIT_ONE_FILESYSTEM\") != NULL) {\n\nShould this really trigger for GIT_ONE_FILESYSTEM=0? We already have\ngit_env_bool, which will handle 0/1, true/false, etc. Probably you\nshould use it here.\n\nI am not a big fan of the environment variable name, either, but I don't\nhave another good suggestion. It is closely related to\nGIT_CEILING_DIRECTORIES (in fact, you could probably solve the same\nproblem with GIT_CEILING_DIRECTORIES, but I think your solution is much\nnicer in that it lets the user get away with being less verbose).\n\n> +\t\t\tif (stat(\"..\", &buf))\n> +\t\t\t\tdie_errno(\"failed to stat '..'\");\n> +\t\t\tif (buf.st_dev != current_device)\n> +\t\t\t\tdie(\"refusing to cross filesystem boundary '%s/..'\", cwd);\n> +\t\t}\n\nI agree with Sverre that this message isn't descriptive enough, but I\nlike the suggestion you posted elsewhere in the thread.\n\n-Peff\n"},{"id":"136918","messageId":"20100316032857.GA8734@pixar.com","threadId":"23031","inReplyTo":"20100316023306.GA14253@coredump.intra.peff.net","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-16T03:28:58Z","receivedAt":"2010-03-16T03:28:58Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":">From Jeff King <peff@peff.net>, Mon, Mar 15, 2010 at 10:33:06PM -0400:\n> On Mon, Mar 15, 2010 at 02:40:03PM -0700, Lars Damerow wrote:\n> \n> > +\t\tif (getenv(\"GIT_ONE_FILESYSTEM\") != NULL) {\n> \n> Should this really trigger for GIT_ONE_FILESYSTEM=0? We already have\n> git_env_bool, which will handle 0/1, true/false, etc. Probably you\n> should use it here.\n\nThanks for the pointer--I wasn't aware of git_env_bool. I'll use it\ninstead.\n\n> I am not a big fan of the environment variable name, either, but I don't\n> have another good suggestion. It is closely related to\n> GIT_CEILING_DIRECTORIES (in fact, you could probably solve the same\n> problem with GIT_CEILING_DIRECTORIES, but I think your solution is much\n> nicer in that it lets the user get away with being less verbose).\n\nI was thinking about cp's -x option and its description in the man page\nwhen I chose GIT_ONE_FILESYSTEM. Before I wrote this patch I configured\nmy machines to have their most popular automount points in\nGIT_CEILING_DIRECTORIES, but need a more complete solution and don't\nwant to have a cron job running to keep the list up to date.\n\nDo the overall idea and implementation have enough merit that the patch\ncould get accepted?\n\nthanks,\n-lars\n\n--\nlars r. damerow :: button pusher :: pixar animation studios\n\nThe big print giveth and the small print taketh away.\n"},{"id":"136917","messageId":"20100316033753.GA30332@coredump.intra.peff.net","threadId":"23031","inReplyTo":"20100316032857.GA8734@pixar.com","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-16T03:37:53Z","receivedAt":"2010-03-16T03:37:53Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 15, 2010 at 08:28:58PM -0700, Lars Damerow wrote:\n\n> I was thinking about cp's -x option and its description in the man page\n> when I chose GIT_ONE_FILESYSTEM. Before I wrote this patch I configured\n\nAh, I always just used \"-x\" and didn't know about \"--one-file-system\".\nSo in that way, it makes sense.\n\n> Do the overall idea and implementation have enough merit that the patch\n> could get accepted?\n\nYeah, I think it is an improvement overall.\n\n-Peff\n"},{"id":"136919","messageId":"7vbpeovqyi.fsf@alter.siamese.dyndns.org","threadId":"23031","inReplyTo":"20100316023306.GA14253@coredump.intra.peff.net","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-16T04:19:17Z","receivedAt":"2010-03-16T04:19:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Mar 15, 2010 at 02:40:03PM -0700, Lars Damerow wrote:\n>\n>> +\t\tif (getenv(\"GIT_ONE_FILESYSTEM\") != NULL) {\n>\n> Should this really trigger for GIT_ONE_FILESYSTEM=0? We already have\n> git_env_bool, which will handle 0/1, true/false, etc. Probably you\n> should use it here.\n>\n> I am not a big fan of the environment variable name, either, but I don't\n> have another good suggestion. It is closely related to\n> GIT_CEILING_DIRECTORIES (in fact, you could probably solve the same\n> problem with GIT_CEILING_DIRECTORIES, but I think your solution is much\n> nicer in that it lets the user get away with being less verbose).\n\nYeah, that, or toplevel global option --one-file-system given to \"git\",\nbut I think that is probably too cumbersome.\n\nHow inefficient is it to repeatedly call getenv() in a loop, by the way?\nI think the patch would become easier to read if env_bool() is called once\nat the beginning to set a local variable, and not even do the initial stat()\nfor \".\" if this feature is not asked for.\n"},{"id":"136940","messageId":"20100316055625.GA10907@pixar.com","threadId":"23031","inReplyTo":"7vbpeovqyi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-16T05:56:25Z","receivedAt":"2010-03-16T05:56:25Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":">From Junio C Hamano <gitster@pobox.com>, Mon, Mar 15, 2010 at 09:19:17PM -0700:\n> \n> How inefficient is it to repeatedly call getenv() in a loop, by the way?\n> I think the patch would become easier to read if env_bool() is called once\n> at the beginning to set a local variable, and not even do the initial stat()\n> for \".\" if this feature is not asked for.\n\nAgreed, I didn't do this too efficiently. Thanks for the feedback! I'll\nmake a new patch and resubmit.\n\ncheers,\n-lars\n\n--\nlars r. damerow :: button pusher :: pixar animation studios\n\nWhen in doubt, use brute force.\n"}]}