{"thread":{"id":"23055","subject":"[PATCH 2/3] truncate cwd string before printing error message","startedAt":"2010-03-17T19:55:50Z","lastAt":"2010-04-04T22:39:58Z","messageCount":20,"participants":["Lars R. Damerow","Jeff King","Junio C Hamano","Lars Damerow","Linus Torvalds","Thomas Rast","Erik Faye-Lund","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"137058","messageId":"1268855753-25840-1-git-send-email-lars@pixar.com","threadId":"23055","inReplyTo":null,"subject":"[PATCH v3 0/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars R. Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-17T19:55:50Z","receivedAt":"2010-03-17T19:55:50Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":"\nHere's another try for GIT_ONE_FILESYSTEM.\n\nI took Duy's recommendation not to die() in gentle mode as well as to just use\ncwd in my error messages (after truncating them). I also fixed the problem\nwith the existing error message's use of an untruncated cwd.\n\nThanks for all of the suggestions!\n\nLars R. Damerow (3):\n      config.c: remove static keyword from git_env_bool()\n      truncate cwd string before printing error message\n      Add support for GIT_ONE_FILESYSTEM\n\n Documentation/git.txt |    3 +++\n cache.h               |    1 +\n config.c              |    2 +-\n setup.c               |   28 +++++++++++++++++++++++++++-\n 4 files changed, 32 insertions(+), 2 deletions(-)\n"},{"id":"137057","messageId":"1268855753-25840-2-git-send-email-lars@pixar.com","threadId":"23055","inReplyTo":"1268855753-25840-1-git-send-email-lars@pixar.com","subject":"[PATCH 1/3] config.c: remove static keyword from git_env_bool()","fromName":"Lars R. Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-17T19:55:51Z","receivedAt":"2010-03-17T19:55:51Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":"Since this function is the preferred way to handle boolean environment\nvariables it's useful to have it available to other files.\n\nSigned-off-by: Lars R. Damerow <lars@pixar.com>\n---\n cache.h  |    1 +\n config.c |    2 +-\n 2 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 89f6a40..c29030f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -945,6 +945,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int\n extern int git_config_rename_section(const char *, const char *);\n extern const char *git_etc_gitconfig(void);\n extern int check_repository_format_version(const char *var, const char *value, void *cb);\n+extern int git_env_bool(const char *, int);\n extern int git_config_system(void);\n extern int git_config_global(void);\n extern int config_error_nonbool(const char *);\ndiff --git a/config.c b/config.c\nindex 6963fbe..70e4600 100644\n--- a/config.c\n+++ b/config.c\n@@ -683,7 +683,7 @@ const char *git_etc_gitconfig(void)\n \treturn system_wide;\n }\n \n-static int git_env_bool(const char *k, int def)\n+int git_env_bool(const char *k, int def)\n {\n \tconst char *v = getenv(k);\n \treturn v ? git_config_bool(k, v) : def;\n-- \n1.6.5.2\n"},{"id":"137055","messageId":"1268855753-25840-3-git-send-email-lars@pixar.com","threadId":"23055","inReplyTo":"1268855753-25840-1-git-send-email-lars@pixar.com","subject":"[PATCH 2/3] truncate cwd string before printing error message","fromName":"Lars R. Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-17T19:55:52Z","receivedAt":"2010-03-17T19:55:52Z","isPatch":true,"sender":{"key":"lars@pixar.com","avatar":"https://avatars.githubusercontent.com/u/318366?v=4"},"body":"Without this truncation the error message printed only shows the cwd\nfrom the start of the search, not where it failed.\n\nSigned-off-by: Lars R. Damerow <lars@pixar.com>\n---\n setup.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 5716d90..f0b56b9 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -422,8 +422,10 @@ 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 (chdir(\"..\"))\n+\t\tif (chdir(\"..\")) {\n+\t\t\tcwd[offset] = '\\0';\n \t\t\tdie_errno(\"Cannot change to '%s/..'\", cwd);\n+\t\t}\n \t}\n \n \tinside_git_dir = 0;\n-- \n1.6.5.2\n"},{"id":"137056","messageId":"1268855753-25840-4-git-send-email-lars@pixar.com","threadId":"23055","inReplyTo":"1268855753-25840-1-git-send-email-lars@pixar.com","subject":"[PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars R. Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-17T19:55:53Z","receivedAt":"2010-03-17T19:55:53Z","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               |   24 ++++++++++++++++++++++++\n 2 files changed, 27 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 f0b56b9..ef23e79 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, one_filesystem = 0;\n+\tstruct stat buf;\n \n \t/*\n \t * Let's assume that we are in a git repository.\n@@ -390,6 +392,11 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t *   etc.\n \t */\n \toffset = len = strlen(cwd);\n+\tif ((one_filesystem = git_env_bool(\"GIT_ONE_FILESYSTEM\", 0))) {\n+\t\tif (stat(\".\", &buf))\n+\t\t\tdie_errno(\"failed to stat '.'\");\n+\t\tcurrent_device = buf.st_dev;\n+\t}\n \tfor (;;) {\n \t\tgitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);\n \t\tif (gitfile_dir) {\n@@ -422,6 +429,23 @@ 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 (one_filesystem) {\n+\t\t\tif (stat(\"..\", &buf)) {\n+\t\t\t\tcwd[offset] = '\\0';\n+\t\t\t\tdie_errno(\"failed to stat '%s/..'\", cwd);\n+\t\t\t}\n+\t\t\tif (buf.st_dev != current_device) {\n+\t\t\t\tif (nongit_ok) {\n+\t\t\t\t\tif (chdir(cwd))\n+\t\t\t\t\t\tdie_errno(\"Cannot come back to cwd\");\n+\t\t\t\t\t*nongit_ok = 1;\n+\t\t\t\t\treturn NULL;\n+\t\t\t\t}\n+\t\t\t\tcwd[offset] = '\\0';\n+\t\t\t\tdie(\"Not a git repository (or any parent up to mount parent %s)\\n\"\n+\t\t\t\t\t\"Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is set.\", cwd);\n+\t\t\t}\n+\t\t}\n \t\tif (chdir(\"..\")) {\n \t\t\tcwd[offset] = '\\0';\n \t\t\tdie_errno(\"Cannot change to '%s/..'\", cwd);\n-- \n1.6.5.2\n"},{"id":"137998","messageId":"20100328092253.GA17563@coredump.intra.peff.net","threadId":"23055","inReplyTo":"1268855753-25840-4-git-send-email-lars@pixar.com","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-28T09:22:54Z","receivedAt":"2010-03-28T09:22:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 17, 2010 at 12:55:53PM -0700, Lars R. Damerow wrote:\n\n> This patch makes git pay attention to the GIT_ONE_FILESYSTEM environment\n> variable. When that variable is set, git will stop searching for a\n> GIT_DIR when it attempts to cross a filesystem boundary.\n> \n> When working in an environment with too many automount points to make\n> maintaining a GIT_CEILING_DIRECTORIES list enjoyable, GIT_ONE_FILESYSTEM\n> gives the option of turning all such attempts off with one setting.\n\nThanks, this version (and the whole series) looks good to me, with two\nminor nits below.\n\nAs far as a command-line option or a config option, I don't see the\npoint. It seems to me something you would want enabled all the time, not\na one-shot option, so a command-line option doesn't make much sense\n(after all, you could just use --git-dir at that point, which would be\neven faster). A config option might be useful, but I think it might be\ntricky to implement due to the startup sequence.  If anybody disagrees,\nthey can always build on top of your series very easily.\n\n> diff --git a/Documentation/git.txt b/Documentation/git.txt\n> index 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\nWe should give the user a little more information than that.\nSpecifically:\n\n  - what form should the value take?\n\n  - how does it interact with GIT_DIR?\n\nAlso, we use the phrase \"repository directory\" in\nGIT_CEILING_DIRECTORIES, so we should probably do the same here.\n\nSo how about this squashed into your patch?\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex e7ebaaa..bf1b45e 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -531,7 +531,10 @@ git so take care if using Cogito etc.\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+\tIf set to a true value (\"true\" or a non-zero integer), stop at\n+\tfilesystem boundaries when looking for a repository directory.\n+\tLike 'GIT_CEILING_DIRECTORIES', it will not affect an explicit\n+\trespository directory set via 'GIT_DIR' or on the command line.\n \n git Commits\n ~~~~~~~~~~~\n\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -390,6 +392,11 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>  \t *   etc.\n>  \t */\n>  \toffset = len = strlen(cwd);\n> +\tif ((one_filesystem = git_env_bool(\"GIT_ONE_FILESYSTEM\", 0))) {\n> +\t\tif (stat(\".\", &buf))\n> +\t\t\tdie_errno(\"failed to stat '.'\");\n> +\t\tcurrent_device = buf.st_dev;\n> +\t}\n\nStyle nit. I know you did the proper () to silence the compiler warning,\nbut we usually avoid assignment-inside-conditional altogether.\nPersonally I don't really care either way.\n\nWith those fixes, I think it should be ready for 'next'.\n\n-Peff\n"},{"id":"138001","messageId":"20100328120532.GA6131@coredump.intra.peff.net","threadId":"23055","inReplyTo":"20100328092253.GA17563@coredump.intra.peff.net","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-28T12:05:32Z","receivedAt":"2010-03-28T12:05:32Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Mar 28, 2010 at 05:22:54AM -0400, Jeff King wrote:\n\n> > --- a/setup.c\n> > +++ b/setup.c\n> > @@ -390,6 +392,11 @@ const char *setup_git_directory_gently(int *nongit_ok)\n> >  \t *   etc.\n> >  \t */\n> >  \toffset = len = strlen(cwd);\n> > +\tif ((one_filesystem = git_env_bool(\"GIT_ONE_FILESYSTEM\", 0))) {\n> > +\t\tif (stat(\".\", &buf))\n> > +\t\t\tdie_errno(\"failed to stat '.'\");\n> > +\t\tcurrent_device = buf.st_dev;\n> > +\t}\n> \n> Style nit. I know you did the proper () to silence the compiler warning,\n> but we usually avoid assignment-inside-conditional altogether.\n> Personally I don't really care either way.\n\nActually I take this back. It is in our CodingStyle guide, but we\nviolate it all over the place (my grep counted 522). Perhaps it should\nbe removed from CodingStyle.\n\n-Peff\n"},{"id":"138016","messageId":"7vr5n44crq.fsf@alter.siamese.dyndns.org","threadId":"23055","inReplyTo":"20100328092253.GA17563@coredump.intra.peff.net","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-28T16:44:09Z","receivedAt":"2010-03-28T16:44:09Z","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> With those fixes, I think it should be ready for 'next'.\n\nYeah, looks nice; thanks both.\n"},{"id":"138023","messageId":"20100328173225.GA2397@pixar.com","threadId":"23055","inReplyTo":"7vr5n44crq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Lars Damerow","fromEmail":"lars@pixar.com","sentAt":"2010-03-28T17:32:25Z","receivedAt":"2010-03-28T17:32: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>, Sun, Mar 28, 2010 at 09:44:09AM -0700:\n> Jeff King <peff@peff.net> writes:\n> \n> > With those fixes, I think it should be ready for 'next'.\n> \n> Yeah, looks nice; thanks both.\n\nThanks all for the suggestions! Jeff, shall I just squash in the doc\npatch you sent and resubmit the patches to the list?\n\n-lars\n\n--\nlars r. damerow :: button pusher :: pixar animation studios\n"},{"id":"138187","messageId":"20100330155850.GA17763@coredump.intra.peff.net","threadId":"23055","inReplyTo":"20100328173225.GA2397@pixar.com","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-30T15:58:51Z","receivedAt":"2010-03-30T15:58:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Mar 28, 2010 at 10:32:25AM -0700, Lars Damerow wrote:\n\n> > > With those fixes, I think it should be ready for 'next'.\n> > \n> > Yeah, looks nice; thanks both.\n> \n> Thanks all for the suggestions! Jeff, shall I just squash in the doc\n> patch you sent and resubmit the patches to the list?\n\nNo need. Usually Junio's \"thanks both\" means he picked up the patches\nand squashed it himself, and indeed, it looks like he has your patches\n(with my doc change) in his 'pu' branch.\n\n-Peff\n"},{"id":"138228","messageId":"alpine.LFD.2.00.1003301537150.3707@i5.linux-foundation.org","threadId":"23055","inReplyTo":"7vr5n44crq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2010-03-30T22:43:01Z","receivedAt":"2010-03-30T22:43:01Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 28 Mar 2010, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > With those fixes, I think it should be ready for 'next'.\n> \n> Yeah, looks nice; thanks both.\n\nI realize that I'm late to the party, but I do wonder if the \"one \nfilesystem\" mode shouldn't be the default, rather than be enabled by a \nconfig option? IOW, just switch the meaning of the config option the other \nway.\n\nI suspect that it is _very_ unusual to have a source repo that crosses \nmultiple filesystems, and the original reason for this patch-series seems \nto me to be likely to be more common than that multi-fs case. So having \nthe logic go the other way would seem to match the common case, no?\n\n\t\t\tLinus\n"},{"id":"138230","messageId":"201003310059.33937.trast@student.ethz.ch","threadId":"23055","inReplyTo":"alpine.LFD.2.00.1003301537150.3707@i5.linux-foundation.org","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-03-30T22:59:33Z","receivedAt":"2010-03-30T22:59:33Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Linus Torvalds wrote:\n> \n> I suspect that it is _very_ unusual to have a source repo that crosses \n> multiple filesystems, and the original reason for this patch-series seems \n> to me to be likely to be more common than that multi-fs case. So having \n> the logic go the other way would seem to match the common case, no?\n\nNot sure if I'm the only one, but I noticed at some point that\nmounting the t/ directory of git.git on tmpfs gives a huge speed boost\nto the test suite...\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"138231","messageId":"20100330230211.GC608@coredump.intra.peff.net","threadId":"23055","inReplyTo":"alpine.LFD.2.00.1003301537150.3707@i5.linux-foundation.org","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-30T23:02:11Z","receivedAt":"2010-03-30T23:02:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 30, 2010 at 03:43:01PM -0700, Linus Torvalds wrote:\n\n> I realize that I'm late to the party, but I do wonder if the \"one \n> filesystem\" mode shouldn't be the default, rather than be enabled by a \n> config option? IOW, just switch the meaning of the config option the other \n> way.\n\nFashionably late, of course. I agree with your reasoning that it is\na more sane default. The only thing that would make me hesitate on it\nnow is that it is a behavior change. I suspect the group we would be\nbreaking is small or even zero, though.\n\n-Peff\n"},{"id":"138232","messageId":"20100330230408.GD608@coredump.intra.peff.net","threadId":"23055","inReplyTo":"201003310059.33937.trast@student.ethz.ch","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-30T23:04:08Z","receivedAt":"2010-03-30T23:04:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 31, 2010 at 12:59:33AM +0200, Thomas Rast wrote:\n\n> Linus Torvalds wrote:\n> > \n> > I suspect that it is _very_ unusual to have a source repo that crosses \n> > multiple filesystems, and the original reason for this patch-series seems \n> > to me to be likely to be more common than that multi-fs case. So having \n> > the logic go the other way would seem to match the common case, no?\n> \n> Not sure if I'm the only one, but I noticed at some point that\n> mounting the t/ directory of git.git on tmpfs gives a huge speed boost\n> to the test suite...\n\nI noticed it, too, but my solution was a little different:\n\n  $ git show f423ef5f\n    tests: allow user to specify trash directory location\n\n    The tests generate a large amount of I/O activity creating\n    and destroying repositories and files. We can improve the\n    time it takes to run the test suite by creating trash\n    directories on filesystems with better performance\n    characteristic, even though we may not want the rest of the\n    git repository on those filesystems (e.g., because they are\n    not network connected, or because they are temporary\n    ramdisks).\n\n    For example, on a dual processor system:\n\n      $ cd t && time make -j32\n      real    1m51.562s\n      user    0m59.260s\n      sys     1m20.933s\n\n      # /dev/shm is tmpfs\n      $ cd t && time make -j32 GIT_TEST_OPTS=\"--root=/dev/shm\"\n      real    1m1.484s\n      user    0m53.555s\n      sys     1m5.264s\n\n-Peff\n"},{"id":"138233","messageId":"7vhbnxs8ws.fsf@alter.siamese.dyndns.org","threadId":"23055","inReplyTo":"20100330230211.GC608@coredump.intra.peff.net","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-30T23:10:27Z","receivedAt":"2010-03-30T23:10:27Z","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 Tue, Mar 30, 2010 at 03:43:01PM -0700, Linus Torvalds wrote:\n>\n>> I realize that I'm late to the party, but I do wonder if the \"one \n>> filesystem\" mode shouldn't be the default, rather than be enabled by a \n>> config option? IOW, just switch the meaning of the config option the other \n>> way.\n>\n> Fashionably late, of course. I agree with your reasoning that it is\n> a more sane default. The only thing that would make me hesitate on it\n> now is that it is a behavior change. I suspect the group we would be\n> breaking is small or even zero, though.\n\nYeah, I think I agree with the reasoning, and it is not even _late_, as\nthe feature hasn't escaped the lab yet.\n"},{"id":"138239","messageId":"alpine.LFD.2.00.1003301610151.3707@i5.linux-foundation.org","threadId":"23055","inReplyTo":"20100330230211.GC608@coredump.intra.peff.net","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2010-03-30T23:12:49Z","receivedAt":"2010-03-30T23:12:49Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 30 Mar 2010, Jeff King wrote:\n> \n> Fashionably late, of course. I agree with your reasoning that it is\n> a more sane default. The only thing that would make me hesitate on it\n> now is that it is a behavior change. I suspect the group we would be\n> breaking is small or even zero, though.\n\nWell, I have to admit that I'm a _tiny_ bit nervous that some odd OS or \nfilesystem has special magic st_dev rules so that it changes randomly even \nwithin a filesystem, but that would be very non-posix (think of the \nconfusion it would cause standard UNIX tools like 'find -xdev' etc), so \nit's more a worry of \"I have no idea what st_dev means on Windows\" than \nanything really solid.\n\n\t\t\tLinus\n"},{"id":"138243","messageId":"40aa078e1003301754u3a1e5e9je7bb2aa2dc04f6a1@mail.gmail.com","threadId":"23055","inReplyTo":"alpine.LFD.2.00.1003301610151.3707@i5.linux-foundation.org","subject":"Re: [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-03-31T00:54:24Z","receivedAt":"2010-03-31T00:54:24Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Mar 31, 2010 at 1:12 AM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n>\n>\n> On Tue, 30 Mar 2010, Jeff King wrote:\n>>\n>> Fashionably late, of course. I agree with your reasoning that it is\n>> a more sane default. The only thing that would make me hesitate on it\n>> now is that it is a behavior change. I suspect the group we would be\n>> breaking is small or even zero, though.\n>\n> Well, I have to admit that I'm a _tiny_ bit nervous that some odd OS or\n> filesystem has special magic st_dev rules so that it changes randomly even\n> within a filesystem, but that would be very non-posix (think of the\n> confusion it would cause standard UNIX tools like 'find -xdev' etc), so\n> it's more a worry of \"I have no idea what st_dev means on Windows\" than\n> anything really solid.\n>\n\nst_dev means \"Drive number of the disk containing the file (same as\nst_rdev).\"[1], and mounting file systems as subdirs of other file\nsystems is rare (but possible) on Windows.\n\nHowever, in our (f)stat implementation, st_dev means 0 -- but this\nmight be possible to improve on.\n\n[1]: http://msdn.microsoft.com/en-us/library/14h5k7ff(VS.71).aspx\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"138545","messageId":"7v4ojr85ee.fsf_-_@alter.siamese.dyndns.org","threadId":"23055","inReplyTo":"40aa078e1003301754u3a1e5e9je7bb2aa2dc04f6a1@mail.gmail.com","subject":"[PATCH] GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundaries","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-04T18:00:09Z","receivedAt":"2010-04-04T18:00:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Regarding the new environment variable, Linus Torvalds\n<torvalds@linux-foundation.org> writes on Tue, 30 Mar 2010 in\n<alpine.LFD.2.00.1003301537150.3707@i5.linux-foundation.org>:\n\n    I suspect that it is _very_ unusual to have a source repo that crosses\n    multiple filesystems, and the original reason for this patch-series\n    seems to me to be likely to be more common than that multi-fs case. So\n    having the logic go the other way would seem to match the common case,\n    no?\n\nThe \"crossing filesystem boundary\" condition is checked by comparing\nst_dev field in the result from stat(2).  This is slightly worrysome if\nnon-POSIX ports return different values in the field even for directories\nin the same work tree extracted to the same \"filesystem\".  Erik Faye-Lund\nconfirms that in the msysgit port st_dev is 0, so this should be safe, as\n\"even Windows is safe\" ;-)\n\nThis will affect those who use /.git to cram /etc and /home/me in the same\nrepostiory, /home is mounted from non-root filesystem, and a git operation\nis done from inside /home/me/src.  But that is such a corner case we don't\nwant to give preference over helping people who will benefit from having\nthis default so that they do not have to suffer from slow automounters.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I agree with Linus that it make sense to flip the default, but this\n   should probably have to wait for at least two release cycles for the\n   usual backward-compatibility rules.\n\n   I wonder if \"git add\" and friends should also notice it and warn.  If\n   you have more than one values of ce->ce_dev in the index, it means that\n   the working tree spans more than one filesystem and from a subdirectory\n   with an entry that has a ce->ce_dev different from the value for a path\n   at the top of the work tree, you will not be able to discover the top\n   of the tree without GIT_ONE_FILESYSTEM set to true.  A likely scenario\n   for this to happen would be:\n\n    (1) You have a tarball of some sort; you extract it $there;\n\n\t$ mkdir $there && cd $there\n        $ tar xf /var/tmp/tarball.tar\n\n    (2) You notice the filesystem lacks enough free space, and move some\n        part (say \"images/\") to a separate filesystem, and bind-mount;\n\n        $ mv images $another/. && rm -fr images && mkdir images\n        $ mount --bind $another/images images\n\n    (3) You add everything to start the project;\n\n        $ git init && git add .\n\n        Up to this point it would work (you are at the top of the working\n        tree).  And this is the point we _could_ notice and warn that you\n        will have trouble in step (4).\n\n    (4) Go down to a subdirectory and start futzing;\n\n\t$ cd images && gimp naughty.jpg && git add -u\n\n Documentation/git.txt |   12 ++++++++----\n setup.c               |    4 ++--\n 2 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex bf1b45e..aa62083 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -531,10 +531,14 @@ git so take care if using Cogito etc.\n \t(Useful for excluding slow-loading network directories.)\n \n 'GIT_ONE_FILESYSTEM'::\n-\tIf set to a true value (\"true\" or a non-zero integer), stop at\n-\tfilesystem boundaries when looking for a repository directory.\n-\tLike 'GIT_CEILING_DIRECTORIES', it will not affect an explicit\n-\trespository directory set via 'GIT_DIR' or on the command line.\n+\tWhen run in a directory that does not have \".git\" repository\n+\tdirectory, git tries to find such a directory in the parent\n+\tdirectories to find the top of the working tree, but by default it\n+\tdoes not cross filesystem boundaries.  This environment variable\n+\tcan be set to false value (\"false\" or zero) to tell git not to\n+\tstop at filesystem boundaries.  Like 'GIT_CEILING_DIRECTORIES',\n+\tthis will not affect an explicit respository directory set via\n+\t'GIT_DIR' or on the command line.\n \n git Commits\n ~~~~~~~~~~~\ndiff --git a/setup.c b/setup.c\nindex 8b911b1..d290633 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -323,7 +323,7 @@ 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, one_filesystem = 0;\n+\tint current_device = 0, one_filesystem = 1;\n \tstruct stat buf;\n \n \t/*\n@@ -444,7 +444,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\t\t}\n \t\t\t\tcwd[offset] = '\\0';\n \t\t\t\tdie(\"Not a git repository (or any parent up to mount parent %s)\\n\"\n-\t\t\t\t\t\"Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is set.\", cwd);\n+\t\t\t\t\"Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is true.\", cwd);\n \t\t\t}\n \t\t}\n \t\tif (chdir(\"..\")) {\n-- \n1.7.0.4.552.gc303c1\n"},{"id":"138566","messageId":"7vzl1iyhof.fsf_-_@alter.siamese.dyndns.org","threadId":"23055","inReplyTo":"7v4ojr85ee.fsf_-_@alter.siamese.dyndns.org","subject":"[PATCH] Rename ONE_FILESYSTEM to DISCOVERY_ACROSS_FILESYSTEM","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-04T22:30:24Z","receivedAt":"2010-04-04T22:30:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If a missing ONE_FILESYSTEM defaults to true, the only users who set this\nvariable set it to false to tell git not to limit the discovery to one\nfilesystem; there are too many negations in one sentence to make a simple\npanda brain dizzy.\n\nUse the variable GIT_DISCOVERY_ACROSS_FILESYSTEM that changes the\nbehaviour from the default \"limit to one filesystem\" to \"cross the\nboundary as I ask you to\"; makes the semantics much more straight\nforward.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n Documentation/git.txt |   10 +++++-----\n setup.c               |    2 +-\n 2 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex aa62083..eb78a2b 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -530,15 +530,15 @@ 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+'GIT_DISCOVERY_ACROSS_FILESYSTEM'::\n \tWhen run in a directory that does not have \".git\" repository\n \tdirectory, git tries to find such a directory in the parent\n \tdirectories to find the top of the working tree, but by default it\n \tdoes not cross filesystem boundaries.  This environment variable\n-\tcan be set to false value (\"false\" or zero) to tell git not to\n-\tstop at filesystem boundaries.  Like 'GIT_CEILING_DIRECTORIES',\n-\tthis will not affect an explicit respository directory set via\n-\t'GIT_DIR' or on the command line.\n+\tcan be set to true to tell git not to stop at filesystem\n+\tboundaries.  Like 'GIT_CEILING_DIRECTORIES', this will not affect\n+\tan explicit respository directory set via 'GIT_DIR' or on the\n+\tcommand line.\n \n git Commits\n ~~~~~~~~~~~\ndiff --git a/setup.c b/setup.c\nindex d290633..5a26b5b 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -392,7 +392,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t *   etc.\n \t */\n \toffset = len = strlen(cwd);\n-\tone_filesystem = git_env_bool(\"GIT_ONE_FILESYSTEM\", 0);\n+\tone_filesystem = !git_env_bool(\"GIT_DISCOVERY_ACROSS_FILESYSTEM\", 0);\n \tif (one_filesystem) {\n \t\tif (stat(\".\", &buf))\n \t\t\tdie_errno(\"failed to stat '.'\");\n-- \n1.7.0.4.552.gc303c1\n"},{"id":"138570","messageId":"vpqd3ye26a6.fsf@bauges.imag.fr","threadId":"23055","inReplyTo":"7vzl1iyhof.fsf_-_@alter.siamese.dyndns.org","subject":"Re: [PATCH] Rename ONE_FILESYSTEM to DISCOVERY_ACROSS_FILESYSTEM","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-04-04T22:37:37Z","receivedAt":"2010-04-04T22:37:37Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> If a missing ONE_FILESYSTEM defaults to true, the only users who set this\n> variable set it to false to tell git not to limit the discovery to one\n> filesystem; there are too many negations in one sentence to make a simple\n> panda brain dizzy.\n\nRight.\n\n+\tan explicit respository directory set via 'GIT_DIR' or on the\n\nWhile you're there, you can spell respository as \"repository\" ;-).\n\n> diff --git a/setup.c b/setup.c\n> index d290633..5a26b5b 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -392,7 +392,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>  \t *   etc.\n>  \t */\n>  \toffset = len = strlen(cwd);\n> -\tone_filesystem = git_env_bool(\"GIT_ONE_FILESYSTEM\", 0);\n> +\tone_filesystem = !git_env_bool(\"GIT_DISCOVERY_ACROSS_FILESYSTEM\", 0);\n>  \tif (one_filesystem) {\n>  \t\tif (stat(\".\", &buf))\n>  \t\t\tdie_errno(\"failed to stat '.'\");\n\nI guess you still have one instance of GIT_ONE_FILESYSTEM a little\nbelow in the error message:\n\n\"Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is true.\"\n\nwhich should become\n\n\"Stopping at filesystem boundary since GIT_DISCOVERY_ACROSS_FILESYSTEM\\n\"\n\"is not set.\"\n\nor so.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"138569","messageId":"7vvdc6yh8h.fsf@alter.siamese.dyndns.org","threadId":"23055","inReplyTo":"7v4ojr85ee.fsf_-_@alter.siamese.dyndns.org","subject":"Re: [PATCH] GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundaries","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-04T22:39:58Z","receivedAt":"2010-04-04T22:39:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>    I wonder if \"git add\" and friends should also notice it and warn.  If\n>    you have more than one values of ce->ce_dev in the index, it means that\n>    the working tree spans more than one filesystem and from a subdirectory\n>    with an entry that has a ce->ce_dev different from the value for a path\n>    at the top of the work tree, you will not be able to discover the top\n>    of the tree without GIT_ONE_FILESYSTEM set to true.  A likely scenario\n>    for this to happen would be:\n>\n>     (1) You have a tarball of some sort; you extract it $there;\n>\n> \t$ mkdir $there && cd $there\n>         $ tar xf /var/tmp/tarball.tar\n>\n>     (2) You notice the filesystem lacks enough free space, and move some\n>         part (say \"images/\") to a separate filesystem, and bind-mount;\n>\n>         $ mv images $another/. && rm -fr images && mkdir images\n>         $ mount --bind $another/images images\n>\n>     (3) You add everything to start the project;\n>\n>         $ git init && git add .\n>\n>         Up to this point it would work (you are at the top of the working\n>         tree).  And this is the point we _could_ notice and warn that you\n>         will have trouble in step (4).\n>\n>     (4) Go down to a subdirectory and start futzing;\n>\n> \t$ cd images && gimp naughty.jpg && git add -u\n\nAnd this adds such a check.\n\n read-cache.c |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex f1f789b..486bb2a 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1550,6 +1550,7 @@ int write_index(struct index_state *istate, int newfd)\n \tstruct cache_entry **cache = istate->cache;\n \tint entries = istate->cache_nr;\n \tstruct stat st;\n+\tint more_than_one_dev;\n \n \tfor (i = removed = extended = 0; i < entries; i++) {\n \t\tif (cache[i]->ce_flags & CE_REMOVE)\n@@ -1572,6 +1573,7 @@ int write_index(struct index_state *istate, int newfd)\n \tif (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)\n \t\treturn -1;\n \n+\tmore_than_one_dev = 0;\n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = cache[i];\n \t\tif (ce->ce_flags & CE_REMOVE)\n@@ -1580,8 +1582,15 @@ int write_index(struct index_state *istate, int newfd)\n \t\t\tce_smudge_racily_clean_entry(ce);\n \t\tif (ce_write_entry(&c, newfd, ce) < 0)\n \t\t\treturn -1;\n+\t\tif (i && ce->ce_dev != cache[0]->ce_dev)\n+\t\t\tmore_than_one_dev = 1;\n \t}\n \n+\tif (more_than_one_dev &&\n+\t    !git_env_bool(\"GIT_DISCOVERY_ACROSS_FILESYSTEM\", 0))\n+\t\twarning(\"working tree spans across filesystems but \"\n+\t\t\t\"GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\");\n+\n \t/* Write extension data here */\n \tif (istate->cache_tree) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n"}]}