{"thread":{"id":"52809","subject":"[RFC PATCH] prefix_path: show gitdir when arg is outside repo","startedAt":"2020-02-14T23:29:40Z","lastAt":"2020-03-03T17:07:00Z","messageCount":9,"participants":["emilyshaffer@google.com","brian m. carlson","Emily Shaffer","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"391808","messageId":"20200214232933.243520-1-emilyshaffer@google.com","threadId":"52809","inReplyTo":null,"subject":"[RFC PATCH] prefix_path: show gitdir when arg is outside repo","fromName":"","fromEmail":"emilyshaffer@google.com","sentAt":"2020-02-14T23:29:33Z","receivedAt":"2020-02-14T23:29:40Z","isPatch":true,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"From: Emily Shaffer <emilyshaffer@google.com>\n\nWhen developing a script, it can be painful to understand why Git thinks\nsomething is outside the current repo, if the current repo isn't what\nthe user thinks it is. Since this can be tricky to diagnose, especially\nin cases like submodules or nested worktrees, let's give the user a hint\nabout which repository is offended about that path.\n\nSigned-off-by: Emily Shaffer <emilyshaffer@google.com>\n---\nThis one comes from a user feature request. This user is running some\nGit client commands on a build machine somewhere and finding it hard to\nreason about the cause of the \"outside repo\" error.\n\nI see two arguments:\n\nFor:\n - A user checking their own `pwd` might still not come to the same\n   conclusion Git does about the current repo, if their filesystem is in\n   some weird state\n - This warning is intended for human eyes (die(), stderr) so it's reasonable\n   to give some info to make the human's life easier\n\nAgainst:\n - It's chatty, especially given the absolute directory. This may be a\n   pretty common mistake ('git add' with thumbfingers?) so it could be\n   chatty, frequently - not great.\n   (Sidebar: Just including the relative directory is really not very\n   useful - since you're still left thinking, \"relative to where?\")\n\nI also dug around a little to see whether I could consolidate the\npathspec.c logic, which is nearly identical to setup.c, into another\nhelper in setup.c (a la prefix_path_1()). But since the die() message is\nsomewhat different, and init_pathspec_item() is the _only_ place which\nuses prefix_path_gently() in this way, it wasn't feasible. (The other\ncaller of prefix_path_gently() is immediately below prefix_path(), and\ndoesn't die at all, print errors, or capture out-params from\nprefix_path_gently().)\n\n - Emily\n\n pathspec.c | 3 ++-\n setup.c    | 3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/pathspec.c b/pathspec.c\nindex 128f27fcb7..5d661df5cf 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n \t\tmatch = prefix_path_gently(prefix, prefixlen,\n \t\t\t\t\t   &prefixlen, copyfrom);\n \t\tif (!match)\n-\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n+\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n+\t\t\t    copyfrom, absolute_path(get_git_dir()));\n \t}\n \n \titem->match = match;\ndiff --git a/setup.c b/setup.c\nindex 12228c0d9c..48cc2320cb 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -121,7 +121,8 @@ char *prefix_path(const char *prefix, int len, const char *path)\n {\n \tchar *r = prefix_path_gently(prefix, len, NULL, path);\n \tif (!r)\n-\t\tdie(_(\"'%s' is outside repository\"), path);\n+\t\tdie(_(\"'%s' is outside repository at '%s'\"), path,\n+\t\t    absolute_path(get_git_dir()));\n \treturn r;\n }\n \n-- \n2.25.0.265.gbab2e86ba0-goog\n\n"},{"id":"391811","messageId":"20200215000230.GA6134@camp.crustytoothpaste.net","threadId":"52809","inReplyTo":"20200214232933.243520-1-emilyshaffer@google.com","subject":"Re: [RFC PATCH] prefix_path: show gitdir when arg is outside repo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-02-15T00:02:30Z","receivedAt":"2020-02-15T00:02:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-02-14 at 23:29:33, emilyshaffer@google.com wrote:\n> From: Emily Shaffer <emilyshaffer@google.com>\n> \n> When developing a script, it can be painful to understand why Git thinks\n> something is outside the current repo, if the current repo isn't what\n> the user thinks it is. Since this can be tricky to diagnose, especially\n> in cases like submodules or nested worktrees, let's give the user a hint\n> about which repository is offended about that path.\n> \n> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n> ---\n> This one comes from a user feature request. This user is running some\n> Git client commands on a build machine somewhere and finding it hard to\n> reason about the cause of the \"outside repo\" error.\n> \n> I see two arguments:\n> \n> For:\n>  - A user checking their own `pwd` might still not come to the same\n>    conclusion Git does about the current repo, if their filesystem is in\n>    some weird state\n>  - This warning is intended for human eyes (die(), stderr) so it's reasonable\n>    to give some info to make the human's life easier\n> \n> Against:\n>  - It's chatty, especially given the absolute directory. This may be a\n>    pretty common mistake ('git add' with thumbfingers?) so it could be\n>    chatty, frequently - not great.\n>    (Sidebar: Just including the relative directory is really not very\n>    useful - since you're still left thinking, \"relative to where?\")\n\nI'm very much in favor of this patch.  I recently ran into a similar\nproblem with Git LFS with path canonicalization and having both paths in\nthe error message made it immediately obvious what the problem was.\n\n> diff --git a/pathspec.c b/pathspec.c\n> index 128f27fcb7..5d661df5cf 100644\n> --- a/pathspec.c\n> +++ b/pathspec.c\n> @@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n>  \t\tmatch = prefix_path_gently(prefix, prefixlen,\n>  \t\t\t\t\t   &prefixlen, copyfrom);\n>  \t\tif (!match)\n> -\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n> +\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n> +\t\t\t    copyfrom, absolute_path(get_git_dir()));\n\nDo we want the top level directory in these two spots instead of the git\ndirectory?  I suspect that might be more helpful, since it looks like\nwe're dealing with working tree files.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"391819","messageId":"20200215004606.GM190927@google.com","threadId":"52809","inReplyTo":"20200215000230.GA6134@camp.crustytoothpaste.net","subject":"Re: [RFC PATCH] prefix_path: show gitdir when arg is outside repo","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2020-02-15T00:46:06Z","receivedAt":"2020-02-15T00:46:14Z","isPatch":true,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"On Sat, Feb 15, 2020 at 12:02:30AM +0000, brian m. carlson wrote:\n> On 2020-02-14 at 23:29:33, emilyshaffer@google.com wrote:\n> > From: Emily Shaffer <emilyshaffer@google.com>\n> > \n> > When developing a script, it can be painful to understand why Git thinks\n> > something is outside the current repo, if the current repo isn't what\n> > the user thinks it is. Since this can be tricky to diagnose, especially\n> > in cases like submodules or nested worktrees, let's give the user a hint\n> > about which repository is offended about that path.\n> > \n> > Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n> > ---\n> > This one comes from a user feature request. This user is running some\n> > Git client commands on a build machine somewhere and finding it hard to\n> > reason about the cause of the \"outside repo\" error.\n> > \n> > I see two arguments:\n> > \n> > For:\n> >  - A user checking their own `pwd` might still not come to the same\n> >    conclusion Git does about the current repo, if their filesystem is in\n> >    some weird state\n> >  - This warning is intended for human eyes (die(), stderr) so it's reasonable\n> >    to give some info to make the human's life easier\n> > \n> > Against:\n> >  - It's chatty, especially given the absolute directory. This may be a\n> >    pretty common mistake ('git add' with thumbfingers?) so it could be\n> >    chatty, frequently - not great.\n> >    (Sidebar: Just including the relative directory is really not very\n> >    useful - since you're still left thinking, \"relative to where?\")\n> \n> I'm very much in favor of this patch.  I recently ran into a similar\n> problem with Git LFS with path canonicalization and having both paths in\n> the error message made it immediately obvious what the problem was.\n> \n> > diff --git a/pathspec.c b/pathspec.c\n> > index 128f27fcb7..5d661df5cf 100644\n> > --- a/pathspec.c\n> > +++ b/pathspec.c\n> > @@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n> >  \t\tmatch = prefix_path_gently(prefix, prefixlen,\n> >  \t\t\t\t\t   &prefixlen, copyfrom);\n> >  \t\tif (!match)\n> > -\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n> > +\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n> > +\t\t\t    copyfrom, absolute_path(get_git_dir()));\n> \n> Do we want the top level directory in these two spots instead of the git\n> directory?  I suspect that might be more helpful, since it looks like\n> we're dealing with working tree files.\n\nI had considered it, and thought .git directory was less ambiguous,\nprimarily for the first bullet in the \"For\" list above - \"for some\nreason, the .git dir I see isn't the one that Git is coming up with\".\nThe .git dir does have a pointer to the worktree ('gitdir' in the\nworktree case and 'config' in the submodule case). Conversely, in both\nthe submodule and worktree cases the worktree contains a \".git\" file\nwith the path to the gitdir.\n\nI also tried the following:\n\n  $ git clone --separate-git-dir=explicit-gitdir https://github.com/git/git\n  explicit-worktree\n  $ cd explicit-gitdir\n  $ grep -Rn \"explicit-worktree\"\n  <no results>\n  $ cd ../explicit-worktree\n  $ cat .git\n  <absolute path to explicit-gitdir>\n\nSo it looks like in the clone with --separate-git-dir case, there's no\nway to identify the worktree from the gitdir.\n\nAll this to say, on second thought, I think you're right. From the\nworktree's top level, the gitdir is consistently findable. From gitdir,\nthe worktree is not consistently findable.\n\nI'll send a reroll.\n\n - Emily\n\n> -- \n> brian m. carlson: Houston, Texas, US\n> OpenPGP: https://keybase.io/bk2204\n\n\n"},{"id":"391820","messageId":"20200215010013.190528-1-emilyshaffer@google.com","threadId":"52809","inReplyTo":"20200214232933.243520-1-emilyshaffer@google.com","subject":"[RFC PATCH v2] prefix_path: show gitdir when arg is outside repo","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2020-02-15T01:00:13Z","receivedAt":"2020-02-15T01:00:20Z","isPatch":true,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"When developing a script, it can be painful to understand why Git thinks\nsomething is outside the current repo, if the current repo isn't what\nthe user thinks it is. Since this can be tricky to diagnose, especially\nin cases like submodules or nested worktrees, let's give the user a hint\nabout which repository is offended about that path.\n\nSigned-off-by: Emily Shaffer <emilyshaffer@google.com>\n---\nAs suggested by brian, print the worktree instead. See\nhttps://lore.kernel.org/git/20200215004606.GM190927@google.com.\n\n pathspec.c | 3 ++-\n setup.c    | 3 ++-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/pathspec.c b/pathspec.c\nindex 128f27fcb7..166d255642 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n \t\tmatch = prefix_path_gently(prefix, prefixlen,\n \t\t\t\t\t   &prefixlen, copyfrom);\n \t\tif (!match)\n-\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n+\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n+\t\t\t    copyfrom, absolute_path(get_git_work_tree()));\n \t}\n \n \titem->match = match;\ndiff --git a/setup.c b/setup.c\nindex 12228c0d9c..4ea7a0b081 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -121,7 +121,8 @@ char *prefix_path(const char *prefix, int len, const char *path)\n {\n \tchar *r = prefix_path_gently(prefix, len, NULL, path);\n \tif (!r)\n-\t\tdie(_(\"'%s' is outside repository\"), path);\n+\t\tdie(_(\"'%s' is outside repository at '%s'\"), path,\n+\t\t    absolute_path(get_git_work_tree()));\n \treturn r;\n }\n \n-- \n2.25.0.265.gbab2e86ba0-goog\n\n"},{"id":"391824","messageId":"20200215025642.GC6134@camp.crustytoothpaste.net","threadId":"52809","inReplyTo":"20200215010013.190528-1-emilyshaffer@google.com","subject":"Re: [RFC PATCH v2] prefix_path: show gitdir when arg is outside repo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-02-15T02:56:42Z","receivedAt":"2020-02-15T03:08:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-02-15 at 01:00:13, Emily Shaffer wrote:\n> When developing a script, it can be painful to understand why Git thinks\n> something is outside the current repo, if the current repo isn't what\n> the user thinks it is. Since this can be tricky to diagnose, especially\n> in cases like submodules or nested worktrees, let's give the user a hint\n> about which repository is offended about that path.\n> \n> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n\nThis looks good to me.  Thanks for this improvement.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"392685","messageId":"20200228195805.GA190372@google.com","threadId":"52809","inReplyTo":"20200215010013.190528-1-emilyshaffer@google.com","subject":"Re: [RFC PATCH v2] prefix_path: show gitdir when arg is outside repo","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2020-02-28T19:58:05Z","receivedAt":"2020-02-28T19:58:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nEmily Shaffer wrote:\n\n> When developing a script, it can be painful to understand why Git thinks\n> something is outside the current repo, if the current repo isn't what\n> the user thinks it is. Since this can be tricky to diagnose, especially\n> in cases like submodules or nested worktrees, let's give the user a hint\n> about which repository is offended about that path.\n>\n> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n> ---\n>  pathspec.c | 3 ++-\n>  setup.c    | 3 ++-\n>  2 files changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/pathspec.c b/pathspec.c\n> index 128f27fcb7..166d255642 100644\n> --- a/pathspec.c\n> +++ b/pathspec.c\n> @@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n>  \t\tmatch = prefix_path_gently(prefix, prefixlen,\n>  \t\t\t\t\t   &prefixlen, copyfrom);\n>  \t\tif (!match)\n> -\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n> +\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n> +\t\t\t    copyfrom, absolute_path(get_git_work_tree()));\n\nThis is producing segfaults when run by magit.  Reproduction recipe:\n\n\tcd .git\n\tgit ls-files ..\n\nExpected result:\n\n\tfatal: ..: '..' is outside repository\n\nActual result:\n\n\tSegmentation fault\n\nDoes this need an extra case to handle when there is no work tree?\n\nThanks,\nJonathan\n\n>  \t}\n>  \n>  \titem->match = match;\n> diff --git a/setup.c b/setup.c\n> index 12228c0d9c..4ea7a0b081 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -121,7 +121,8 @@ char *prefix_path(const char *prefix, int len, const char *path)\n>  {\n>  \tchar *r = prefix_path_gently(prefix, len, NULL, path);\n>  \tif (!r)\n> -\t\tdie(_(\"'%s' is outside repository\"), path);\n> +\t\tdie(_(\"'%s' is outside repository at '%s'\"), path,\n> +\t\t    absolute_path(get_git_work_tree()));\n>  \treturn r;\n>  }\n>  \n"},{"id":"392770","messageId":"20200303021924.GJ212281@google.com","threadId":"52809","inReplyTo":"20200228195805.GA190372@google.com","subject":"Re: [RFC PATCH v2] prefix_path: show gitdir when arg is outside repo","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2020-03-03T02:19:24Z","receivedAt":"2020-03-03T02:19:33Z","isPatch":true,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"On Fri, Feb 28, 2020 at 11:58:05AM -0800, Jonathan Nieder wrote:\n> Hi,\n> \n> Emily Shaffer wrote:\n> \n> > When developing a script, it can be painful to understand why Git thinks\n> > something is outside the current repo, if the current repo isn't what\n> > the user thinks it is. Since this can be tricky to diagnose, especially\n> > in cases like submodules or nested worktrees, let's give the user a hint\n> > about which repository is offended about that path.\n> >\n> > Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n> > ---\n> >  pathspec.c | 3 ++-\n> >  setup.c    | 3 ++-\n> >  2 files changed, 4 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/pathspec.c b/pathspec.c\n> > index 128f27fcb7..166d255642 100644\n> > --- a/pathspec.c\n> > +++ b/pathspec.c\n> > @@ -439,7 +439,8 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n> >  \t\tmatch = prefix_path_gently(prefix, prefixlen,\n> >  \t\t\t\t\t   &prefixlen, copyfrom);\n> >  \t\tif (!match)\n> > -\t\t\tdie(_(\"%s: '%s' is outside repository\"), elt, copyfrom);\n> > +\t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n> > +\t\t\t    copyfrom, absolute_path(get_git_work_tree()));\n> \n> This is producing segfaults when run by magit.  Reproduction recipe:\n> \n> \tcd .git\n> \tgit ls-files ..\n> \n> Expected result:\n> \n> \tfatal: ..: '..' is outside repository\n> \n> Actual result:\n> \n> \tSegmentation fault\n> \n> Does this need an extra case to handle when there is no work tree?\n\nAh, I see it. You're right.\n\nIn that case I'll fall back on the git dir.\n\nWill hopefully have a patch along today. Thanks for reporting it.\n\n - Emily\n\n"},{"id":"392771","messageId":"20200303040506.241376-1-emilyshaffer@google.com","threadId":"52809","inReplyTo":"20200228195805.GA190372@google.com","subject":"[PATCH] prefix_path: show gitdir if worktree unavailable","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2020-03-03T04:05:06Z","receivedAt":"2020-03-03T04:05:16Z","isPatch":true,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"If there is no worktree at present, we can still hint the user about\nGit's current directory by showing them the absolute path to the Git\ndirectory. Even though the Git directory doesn't make it as easy to\nlocate the worktree in question, it can still help a user figure out\nwhat's going on while developing a script.\n\nThis fixes a segmentation fault introduced in e0020b2f829.\n\nSigned-off-by: Emily Shaffer <emilyshaffer@google.com>\n---\nThis patch is built on top of es/outside-repo-errmsg-hints. I think it\ndoesn't need to be, since that change is in master, though.\n\nSounds like there's a segfault in the wild:\nhttps://lore.kernel.org/git/20200228195805.GA190372@google.com\n\nI figured since the error doesn't specify \"this is the worktree\" or\n\"this is the gitdir\" to the user, it didn't need more prettying when\nfalling back to gitdir in this patch.\n\nIt seems to me that if we are checking whether something is inside or\noutside of the repository, we definitely will get a good result from\nget_git_dir() - if there's no Git dir, then there's no repository to be\nin or out of.\n\nCI run here: https://github.com/gitgitgadget/git/pull/572/checks\n\n - Emily\n\n pathspec.c | 8 ++++++--\n setup.c    | 8 ++++++--\n 2 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/pathspec.c b/pathspec.c\nindex 166d255642..8243e06eab 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -438,9 +438,13 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,\n \t} else {\n \t\tmatch = prefix_path_gently(prefix, prefixlen,\n \t\t\t\t\t   &prefixlen, copyfrom);\n-\t\tif (!match)\n+\t\tif (!match) {\n+\t\t\tconst char *hint_path = get_git_work_tree();\n+\t\t\tif (!hint_path)\n+\t\t\t\thint_path = get_git_dir();\n \t\t\tdie(_(\"%s: '%s' is outside repository at '%s'\"), elt,\n-\t\t\t    copyfrom, absolute_path(get_git_work_tree()));\n+\t\t\t    copyfrom, absolute_path(hint_path));\n+\t\t}\n \t}\n \n \titem->match = match;\ndiff --git a/setup.c b/setup.c\nindex 17814a080b..f4897287f7 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -120,9 +120,13 @@ char *prefix_path_gently(const char *prefix, int len,\n char *prefix_path(const char *prefix, int len, const char *path)\n {\n \tchar *r = prefix_path_gently(prefix, len, NULL, path);\n-\tif (!r)\n+\tif (!r) {\n+\t\tconst char *hint_path = get_git_work_tree();\n+\t\tif (!hint_path)\n+\t\t\thint_path = get_git_dir();\n \t\tdie(_(\"'%s' is outside repository at '%s'\"), path,\n-\t\t    absolute_path(get_git_work_tree()));\n+\t\t    absolute_path(hint_path));\n+\t}\n \treturn r;\n }\n \n-- \n2.25.0.265.gbab2e86ba0-goog\n\n"},{"id":"392793","messageId":"xmqq4kv59xlg.fsf@gitster-ct.c.googlers.com","threadId":"52809","inReplyTo":"20200303040506.241376-1-emilyshaffer@google.com","subject":"Re: [PATCH] prefix_path: show gitdir if worktree unavailable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-03-03T17:06:51Z","receivedAt":"2020-03-03T17:07:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Emily Shaffer <emilyshaffer@google.com> writes:\n\n> If there is no worktree at present, we can still hint the user about\n> Git's current directory by showing them the absolute path to the Git\n> directory. Even though the Git directory doesn't make it as easy to\n> locate the worktree in question, it can still help a user figure out\n> what's going on while developing a script.\n>\n> This fixes a segmentation fault introduced in e0020b2f829.\n>\n> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>\n> ---\n> This patch is built on top of es/outside-repo-errmsg-hints. I think it\n> doesn't need to be, since that change is in master, though.\n>\n> Sounds like there's a segfault in the wild:\n\nThanks.  We should protect the fix with a test, no?\n\n>  pathspec.c | 8 ++++++--\n>  setup.c    | 8 ++++++--\n>  2 files changed, 12 insertions(+), 4 deletions(-)\n"}]}