{"thread":{"id":"24683","subject":"[PATCH] More readable 'Not a git repository' messages","startedAt":"2010-08-09T17:24:35Z","lastAt":"2010-08-15T03:36:40Z","messageCount":13,"participants":["Ralf Ebert","Nguyen Thai Ngoc Duy","Jonathan Nieder","Sverre Rabbelier","Jared Hance","Joshua Juran"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"147522","messageId":"i3pdkj$hut$1@dough.gmane.org","threadId":"24683","inReplyTo":null,"subject":"[PATCH] More readable 'Not a git repository' messages","fromName":"Ralf Ebert","fromEmail":"info@ralfebert.de","sentAt":"2010-08-09T17:24:35Z","receivedAt":"2010-08-09T17:24:35Z","isPatch":true,"sender":{"key":"info@ralfebert.de","avatar":"https://gravatar.com/avatar/4cd7ff4e970e3882f949fb8f42b39141307e5e504d199129f1377c9c1aea0cb9?d=mp&s=160"},"body":"Stating the folder concerned with the operation and wording the\nmessages differently make them slightly more readable.\n\nold: Not a git repository (or any of the parent directories): .git\nnew: Not in a git repository: /home/bob/somefolder\n\nold: Not a git repository (or any parent up to mount parent /home/bob)\nold: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM \nnot set).\nnew: Not in a git repository: /home/bob/somefolder\nnew: (stopped searching at /home because GIT_DISCOVERY_ACROSS_FILESYSTEM \nis not set)\n\nSigned-off-by: Ralf Ebert <info@ralfebert.de>\n---\n  setup.c |   11 +++++++----\n  1 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 2769160..e27fbf1 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -321,6 +321,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n  {\n  \tconst char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n  \tconst char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);\n+\tchar cwd_orig[PATH_MAX];\n  \tstatic char cwd[PATH_MAX+1];\n  \tconst char *gitdirenv;\n  \tconst char *gitfile_dir;\n@@ -376,8 +377,9 @@ const char *setup_git_directory_gently(int *nongit_ok)\n  \t\tdie(\"Not a git repository: '%s'\", gitdirenv);\n  \t}\n  -\tif (!getcwd(cwd, sizeof(cwd)-1))\n+\tif (!getcwd(cwd_orig, sizeof(cwd_orig)))\n  \t\tdie_errno(\"Unable to read current working directory\");\n+\tstrcpy(cwd, cwd_orig);\n   \tceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);\n  \tif (ceil_offset < 0 && has_dos_drive_prefix(cwd))\n@@ -431,7 +433,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n  \t\t\t\t*nongit_ok = 1;\n  \t\t\t\treturn NULL;\n  \t\t\t}\n-\t\t\tdie(\"Not a git repository (or any of the parent directories): %s\", \nDEFAULT_GIT_DIR_ENVIRONMENT);\n+\t\t\tdie(\"Not in a git repository: %s\", cwd_orig);\n  \t\t}\n  \t\tif (one_filesystem) {\n  \t\t\tif (stat(\"..\", &buf)) {\n@@ -446,8 +448,9 @@ const char *setup_git_directory_gently(int *nongit_ok)\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\"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM \nnot set).\", cwd);\n+\t\t\t\tdie(\"Not in a git repository: %s\\n\"\n+\t\t\t\t\"(stopped searching at %s because \"\n+\t\t\t\t\"GIT_DISCOVERY_ACROSS_FILESYSTEM is not set)\", cwd_orig, cwd);\n  \t\t\t}\n  \t\t}\n  \t\tif (chdir(\"..\")) {\n-- \n1.7.2.1.44.g721e7.dirty\n"},{"id":"147569","messageId":"AANLkTinttmKi4+EbE54r-GeRbN3_2wxUHu_qJMn5Nysn@mail.gmail.com","threadId":"24683","inReplyTo":"i3pdkj$hut$1@dough.gmane.org","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-09T22:14:23Z","receivedAt":"2010-08-09T22:14:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Aug 10, 2010 at 3:24 AM, Ralf Ebert <info@ralfebert.de> wrote:\n> Stating the folder concerned with the operation and wording the\n> messages differently make them slightly more readable.\n>\n> old: Not a git repository (or any of the parent directories): .git\n> new: Not in a git repository: /home/bob/somefolder\n>\n> old: Not a git repository (or any parent up to mount parent /home/bob)\n> old: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not\n> set).\n> new: Not in a git repository: /home/bob/somefolder\n> new: (stopped searching at /home because GIT_DISCOVERY_ACROSS_FILESYSTEM is\n> not set)\n>\n> Signed-off-by: Ralf Ebert <info@ralfebert.de>\n> ---\n>  setup.c |   11 +++++++----\n>  1 files changed, 7 insertions(+), 4 deletions(-)\n>\n> diff --git a/setup.c b/setup.c\n> index 2769160..e27fbf1 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -321,6 +321,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>  {\n>        const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n>        const char *env_ceiling_dirs =\n> getenv(CEILING_DIRECTORIES_ENVIRONMENT);\n> +       char cwd_orig[PATH_MAX];\n>        static char cwd[PATH_MAX+1];\n>        const char *gitdirenv;\n>        const char *gitfile_dir;\n> @@ -376,8 +377,9 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>                die(\"Not a git repository: '%s'\", gitdirenv);\n>        }\n>  -      if (!getcwd(cwd, sizeof(cwd)-1))\n> +       if (!getcwd(cwd_orig, sizeof(cwd_orig)))\n>                die_errno(\"Unable to read current working directory\");\n> +       strcpy(cwd, cwd_orig);\n>        ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);\n>        if (ceil_offset < 0 && has_dos_drive_prefix(cwd))\n> @@ -431,7 +433,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>                                *nongit_ok = 1;\n>                                return NULL;\n>                        }\n> -                       die(\"Not a git repository (or any of the parent\n> directories): %s\", DEFAULT_GIT_DIR_ENVIRONMENT);\n> +                       die(\"Not in a git repository: %s\", cwd_orig);\n\ncwd can be used in this case.\n\n>                }\n>                if (one_filesystem) {\n>                        if (stat(\"..\", &buf)) {\n> @@ -446,8 +448,9 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>                                        return NULL;\n>                                }\n>                                cwd[offset] = '\\0';\n> -                               die(\"Not a git repository (or any parent up\n> to mount parent %s)\\n\"\n> -                               \"Stopping at filesystem boundary\n> (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\", cwd);\n> +                               die(\"Not in a git repository: %s\\n\"\n> +                               \"(stopped searching at %s because \"\n> +                               \"GIT_DISCOVERY_ACROSS_FILESYSTEM is not\n> set)\", cwd_orig, cwd);\n\nHow about this and avoid adding cwd_orig?\n\n-                               cwd[offset] = '\\0';\n-                               die(\"Not a git repository (or any\nparent up to mount parent %s)\\n\"\n-                               \"Stopping at filesystem boundary\n(GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\", cwd);\n+                               die(\"Not in a git repository: %s\\n\"\n+                               \"(stopped searching at %.*s because \"\n+                               \"GIT_DISCOVERY_ACROSS_FILESYSTEM is\nnot set)\", cwd, offset, cwd);\n-- \nDuy\n"},{"id":"147575","messageId":"i3q0d8$m8f$1@dough.gmane.org","threadId":"24683","inReplyTo":"AANLkTinttmKi4+EbE54r-GeRbN3_2wxUHu_qJMn5Nysn@mail.gmail.com","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Ralf Ebert","fromEmail":"info@ralfebert.de","sentAt":"2010-08-09T22:44:56Z","receivedAt":"2010-08-09T22:44:56Z","isPatch":true,"sender":{"key":"info@ralfebert.de","avatar":"https://gravatar.com/avatar/4cd7ff4e970e3882f949fb8f42b39141307e5e504d199129f1377c9c1aea0cb9?d=mp&s=160"},"body":"Hi Duy,\n\n> How about this and avoid adding cwd_orig?\n>\n> -                               cwd[offset] = '\\0';\n> -                               die(\"Not a git repository (or any\n> parent up to mount parent %s)\\n\"\n> -                               \"Stopping at filesystem boundary\n> (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\", cwd);\n> +                               die(\"Not in a git repository: %s\\n\"\n> +                               \"(stopped searching at %.*s because \"\n> +                               \"GIT_DISCOVERY_ACROSS_FILESYSTEM is\n> not set)\", cwd, offset, cwd);\n\nthis code is inside a loop that goes up in the directory hierarchy. So \ncwd[offset] = '\\0' does not only happen once before dying. Maybe it \ncould be done without copying but I thought keeping a copy of the \nunaltered path might be more readable.\n\n--\nRalf\n"},{"id":"147582","messageId":"20100809230132.GG4429@burratino","threadId":"24683","inReplyTo":"i3q0d8$m8f$1@dough.gmane.org","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-09T23:01:32Z","receivedAt":"2010-08-09T23:01:32Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ralf Ebert wrote:\n\n> this code is inside a loop that goes up in the directory hierarchy.\n> So cwd[offset] = '\\0' does not only happen once before dying.\n\nI hope not, since then the returned cwd value would be useless\nfor restoring the original cwd later.\n\nShameless plug: you may find the version in commit 98937be (i.e.\nbranch jn/maint-setup-fix in pu) more readable. :)\n"},{"id":"147585","messageId":"i3q3ah$upb$1@dough.gmane.org","threadId":"24683","inReplyTo":"20100809230132.GG4429@burratino","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Ralf Ebert","fromEmail":"info@ralfebert.de","sentAt":"2010-08-09T23:34:41Z","receivedAt":"2010-08-09T23:34:41Z","isPatch":true,"sender":{"key":"info@ralfebert.de","avatar":"https://gravatar.com/avatar/4cd7ff4e970e3882f949fb8f42b39141307e5e504d199129f1377c9c1aea0cb9?d=mp&s=160"},"body":"Hi Jonathan,\n\n> I hope not, since then the returned cwd value would be useless\n> for restoring the original cwd later.\n\nyes, right, I misread the code, thanks for taking the time to correct \nme. My C knowledge is dated to say least and being succumbed by all the \nsyntax sugar of dynamic languages, I misread\nif (chdir(\"..\")) { ... }\nas \"if changing the directory worked ok\" :)\n\n> Shameless plug: you may find the version in commit 98937be (i.e.\n> branch jn/maint-setup-fix in pu) more readable. :)\n\nI do, I guess it makes sense to rework the patch on top of that.\n\nWhat I also wanted to try is make the GIT_DISCOVERY_ACROSS_FILESYSTEM \nwarning go away for crypto home volumes, because that's kind of common \nand nobody needs git to discover repositories in this case. Only need to \ncome up with an idea how to detect this case.\n\n--\nRalf\n"},{"id":"147602","messageId":"AANLkTinJ80FT5HMDg6r1Vz+J+oX_35xoWrygE42UAzkA@mail.gmail.com","threadId":"24683","inReplyTo":"i3pdkj$hut$1@dough.gmane.org","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-08-10T02:49:14Z","receivedAt":"2010-08-10T02:49:14Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, Aug 9, 2010 at 12:24, Ralf Ebert <info@ralfebert.de> wrote:\n> Stating the folder concerned with the operation and wording the\n> messages differently make them slightly more readable.\n\nFWIW I like these improvements, nice work.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"147624","messageId":"AANLkTimeizUKBrwibUTnVPZWwU_M72uQTn8ucmjK_V70@mail.gmail.com","threadId":"24683","inReplyTo":"i3q3ah$upb$1@dough.gmane.org","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-10T11:31:12Z","receivedAt":"2010-08-10T11:31:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Aug 10, 2010 at 9:34 AM, Ralf Ebert <info@ralfebert.de> wrote:\n> I do, I guess it makes sense to rework the patch on top of that.\n\nWhile you're working on that, I was thinking that cwd may be long as\nit's absolute path. How about rephrase the error message a little bit\nand give more space for cwd? Something like\n\nNot a git repository: <reason explained>\nStopped at <current cwd>\n-- \nDuy\n"},{"id":"147653","messageId":"20100810155240.GA5116@localhost.localdomain","threadId":"24683","inReplyTo":"i3pdkj$hut$1@dough.gmane.org","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2010-08-10T15:52:40Z","receivedAt":"2010-08-10T15:52:40Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"On Mon, Aug 09, 2010 at 07:24:35PM +0200, Ralf Ebert wrote:\n> old: Not a git repository (or any of the parent directories): .git\n> new: Not in a git repository: /home/bob/somefolder\n\nDon't we lose information here? Perhaps print the value of\nDEFAULT_GIT_DIR_ENVIRONMENT.\n\n> old: Not a git repository (or any parent up to mount parent /home/bob)\n> old: Stopping at filesystem boundary\n> (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n> new: Not in a git repository: /home/bob/somefolder\n> new: (stopped searching at /home because\n> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set)\n\nThis certainly looks good, but some people might not realize /home is\na filesystem boundary (perhaps those who had someone else set up their\nsystem and don't know their partition setup. I suggest:\n\n(stopped searching at the filesystem boundary, /home, because\nGIT_DISCOVERY_ACROSS_FILESYSTEM is not set)\n"},{"id":"147698","messageId":"D944E855-0ECF-41AF-ACD4-8ED8EABCBC1D@gmail.com","threadId":"24683","inReplyTo":"20100810155240.GA5116@localhost.localdomain","subject":"Re: [PATCH] More readable 'Not a git repository' messages","fromName":"Joshua Juran","fromEmail":"jjuran@gmail.com","sentAt":"2010-08-10T22:34:17Z","receivedAt":"2010-08-10T22:34:17Z","isPatch":true,"sender":{"key":"jjuran@gmail.com","avatar":null},"body":"On Aug 10, 2010, at 8:52 AM, Jared Hance wrote:\n\n> On Mon, Aug 09, 2010 at 07:24:35PM +0200, Ralf Ebert wrote:\n>> old: Not a git repository (or any of the parent directories): .git\n>> new: Not in a git repository: /home/bob/somefolder\n>\n> Don't we lose information here? Perhaps print the value of\n> DEFAULT_GIT_DIR_ENVIRONMENT.\n>\n>> old: Not a git repository (or any parent up to mount parent /home/ \n>> bob)\n>> old: Stopping at filesystem boundary\n>> (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n>> new: Not in a git repository: /home/bob/somefolder\n>> new: (stopped searching at /home because\n>> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set)\n>\n> This certainly looks good, but some people might not realize /home is\n> a filesystem boundary (perhaps those who had someone else set up their\n> system and don't know their partition setup. I suggest:\n>\n> (stopped searching at the filesystem boundary, /home, because\n> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set)\n\nIf the search for .git stops at /home or $HOME, why not say nothing at  \nall?  If you've turned /home (or /) into a Git repo, then either you  \nknow what you're doing or you deserve as much pain as possible.  (I  \nhaven't decided which.)\n\nJosh\n"},{"id":"148006","messageId":"i43v6e$q00$1@dough.gmane.org","threadId":"24683","inReplyTo":"i3pdkj$hut$1@dough.gmane.org","subject":"[PATCH/RFC v2] More readable 'Not a git repository' messages","fromName":"Ralf Ebert","fromEmail":"info@ralfebert.de","sentAt":"2010-08-13T17:25:34Z","receivedAt":"2010-08-13T17:25:34Z","isPatch":true,"sender":{"key":"info@ralfebert.de","avatar":"https://gravatar.com/avatar/4cd7ff4e970e3882f949fb8f42b39141307e5e504d199129f1377c9c1aea0cb9?d=mp&s=160"},"body":"* State the folder concerned with the operation\n* GIT_DISCOVERY_ACROSS_FILESYSTEM warning goes first\n* Supressed 'filesystem boundary' warning for $HOME (crypto home volumes\n   are common, having a git repository at $HOME is uncommon)\n* Improved wording of the messages\n\nSigned-off-by: Ralf Ebert <info@ralfebert.de>\n---\n  setup.c |   12 ++++++++----\n  1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 2769160..dc4f2da 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -431,7 +431,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n  \t\t\t\t*nongit_ok = 1;\n  \t\t\t\treturn NULL;\n  \t\t\t}\n-\t\t\tdie(\"Not a git repository (or any of the parent directories): %s\", \nDEFAULT_GIT_DIR_ENVIRONMENT);\n+\t\t\tdie(\"%s is not in a git repository\", cwd);\n  \t\t}\n  \t\tif (one_filesystem) {\n  \t\t\tif (stat(\"..\", &buf)) {\n@@ -445,9 +445,13 @@ const char *setup_git_directory_gently(int *nongit_ok)\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\"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM \nnot set).\", cwd);\n+\n+\t\t\t\tconst char *home = getenv(\"HOME\");\n+\t\t\t\tif (home == NULL || strncmp(home, cwd, offset) != 0) {\n+\t\t\t\t\twarning(\"Stopped searching for repository at %.*s \"\n+\t\t\t\t\t\t\t\"as GIT_DISCOVERY_ACROSS_FILESYSTEM is not set\", offset, cwd);\n+\t\t\t\t}\n+\t\t\t\tdie(\"%s is not in a git repository\", cwd);\n  \t\t\t}\n  \t\t}\n  \t\tif (chdir(\"..\")) {\n-- \n1.7.2.1.96.g07594.dirty\n"},{"id":"148008","messageId":"4994E665-9084-4479-B44F-4D5562CE4BB0@gmail.com","threadId":"24683","inReplyTo":"i43v6e$q00$1@dough.gmane.org","subject":"Re: [PATCH/RFC v2] More readable 'Not a git repository' messages","fromName":"Joshua Juran","fromEmail":"jjuran@gmail.com","sentAt":"2010-08-13T17:30:52Z","receivedAt":"2010-08-13T17:30:52Z","isPatch":true,"sender":{"key":"jjuran@gmail.com","avatar":null},"body":"On Aug 13, 2010, at 10:25 AM, Ralf Ebert wrote:\n\n> * State the folder concerned with the operation\n> * GIT_DISCOVERY_ACROSS_FILESYSTEM warning goes first\n> * Supressed 'filesystem boundary' warning for $HOME (crypto home  \n> volumes\n\ns/Supressed/Suppressed/\n\n>  are common, having a git repository at $HOME is uncommon)\n> * Improved wording of the messages\n\nJosh\n"},{"id":"148122","messageId":"1281840921-1996-1-git-send-email-ralf@ralfebert.de","threadId":"24683","inReplyTo":"i43v6e$q00$1@dough.gmane.org","subject":"[PATCH] setup.c: Improve 'Not a git repository' messages","fromName":"Ralf Ebert","fromEmail":"ralf@ralfebert.de","sentAt":"2010-08-15T02:55:21Z","receivedAt":"2010-08-15T02:55:21Z","isPatch":true,"sender":{"key":"ralf@ralfebert.de","avatar":null},"body":"Changed message \"Not a git repository (or any of the parent directories)\"\nto the more precise message \"No <.git> repository in <path> or its parent\ndirectories\".\n\nIf a filesystem boundary is encountered with\nGIT_DISCOVERY_ACROSS_FILESYSTEM not set, the warning now goes first.\nThe warning is suppressed when search was stopped at $HOME to not confuse\nusers using a crypto home volume (assuming that users having a repository\nat /home or / know what they are doing).\n\nThanks to Duy, Jonathan, Sverre and Josh for commenting.\n\nSigned-off-by: Ralf Ebert <ralf@ralfebert.de>\n---\n setup.c |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 2769160..adabdd8 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -431,7 +431,8 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\t\t*nongit_ok = 1;\n \t\t\t\treturn NULL;\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\tdie(\"No %s repository in %s or its parent directories\",\n+\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, cwd);\n \t\t}\n \t\tif (one_filesystem) {\n \t\t\tif (stat(\"..\", &buf)) {\n@@ -445,9 +446,14 @@ const char *setup_git_directory_gently(int *nongit_ok)\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\"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\", cwd);\n+\t\t\t\tconst char *home = getenv(\"HOME\");\n+\t\t\t\tif (home == NULL || strncmp(home, cwd, offset) != 0) {\n+\t\t\t\t\twarning(\"Stopped searching for %s at %.*s \"\n+\t\t\t\t\t\t\"as GIT_DISCOVERY_ACROSS_FILESYSTEM is not set\",\n+\t\t\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, offset, cwd);\n+\t\t\t\t}\n+\t\t\t\tdie(\"No %s repository in %s or its parent directories\",\n+\t\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, cwd);\n \t\t\t}\n \t\t}\n \t\tif (chdir(\"..\")) {\n-- \n1.7.2.1.96.gb740\n"},{"id":"148123","messageId":"20100815033640.GA20486@burratino","threadId":"24683","inReplyTo":"1281840921-1996-1-git-send-email-ralf@ralfebert.de","subject":"Re: [PATCH] setup.c: Improve 'Not a git repository' messages","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-15T03:36:40Z","receivedAt":"2010-08-15T03:36:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Ralf,\n\nRalf Ebert wrote:\n\n> +++ b/setup.c\n> @@ -431,7 +431,8 @@ const char *setup_git_directory_gently(int *nongit_ok)\n>  \t\t\t\t*nongit_ok = 1;\n>  \t\t\t\treturn NULL;\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\tdie(\"No %s repository in %s or its parent directories\",\n> +\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, cwd);\n\nSo, before:\n\n fatal: Not a git repository (or any of the parent directories): .git\n\nand after:\n\n fatal: No .git repository in /home/jrn/src/some/deeply/nested/path/that/goes/on/for/a/while or its parent directories\n\nThe idea being to give a hint to the confused user.  That sort of\nmakes sense, but I would (warning! nitpicks coming!) prefer something\nalong the lines of\n\n fatal: not a git repository: /home/jrn/src/some/deeply/nested/pa\n hint: This means every candidate metadata (.git) directory considered\n hint: was invalid in some way.\n hint: See \"git help repository-layout\" for more information.\n\nIn other words:\n\n - first, a straightforward error message;\n - cutting off user-specified data at some reasonable length\n   (e.g. 50 chars);\n - avoiding overly specific (false) advice and deferring to\n   documentation for the details.\n\n> @@ -445,9 +446,14 @@ const char *setup_git_directory_gently(int *nongit_ok)\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\"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\", cwd);\n> +\t\t\t\tconst char *home = getenv(\"HOME\");\n> +\t\t\t\tif (home == NULL || strncmp(home, cwd, offset) != 0) {\n> +\t\t\t\t\twarning(\"Stopped searching for %s at %.*s \"\n> +\t\t\t\t\t\t\"as GIT_DISCOVERY_ACROSS_FILESYSTEM is not set\",\n> +\t\t\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, offset, cwd);\n> +\t\t\t\t}\n> +\t\t\t\tdie(\"No %s repository in %s or its parent directories\",\n> +\t\t\t\t\tDEFAULT_GIT_DIR_ENVIRONMENT, cwd);\n\nI don’t understand what’s special about $HOME here.\n\nWould something like the following be okay?\n\n fatal: not a git repository: /home/jrn/src/some/deeply/nested/pa\n info: search stopped at mount parent /home\n hint: This means every candidate metadata (.git) directory considered\n hint: was invalid in some way.\n hint: See \"git help repository-layout\" for more information.\n\nI actually suspect overriding with $GIT_DISCOVERY_ACROSS_FILESYSTEM\nwould be kind of rare, so it might be okay to let the documentation\ntake care of explaining that (provided we include a clear pointer).\n\nJust my two cents.  Feel free to ignore. :)\n"}]}