git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] path_treatment: also ignore $GIT_DIR if it's not .git

From
Duy Nguyen <pclouds@gmail.com>
Date
Dec 1, 2013, 23:02 UTC
Message-ID
<CACsJy8CxR+wj-P+fxF37DU=Tzk=su+V=UudbO7NkqTMS8qTn_w@mail.gmail.com>
In-Reply-To
<20131201190447.GA31367@kaarsemaker.net>

On Mon, Dec 2, 2013 at 2:04 AM, Dennis Kaarsemaker <dennis@kaarsemaker.net> wrote:

Show 21 quoted lines
> We always ignore anything named .git, but we should also ignore the git
> directory if the user overrides it by setting $GIT_DIR
>
> Reported-By: Ingy döt Net <ingy@ingy.net>
> Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
> ---
>  dir.c             | 2 +-
>  t/t7508-status.sh | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/dir.c b/dir.c
> index 23b6de4..884b37d 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -1198,7 +1198,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
>                 return path_none;
>         strbuf_setlen(path, baselen);
>         strbuf_addstr(path, de->d_name);
> -       if (simplify_away(path->buf, path->len, simplify))
> +       if (simplify_away(path->buf, path->len, simplify) || is_git_directory(path->buf))
>                 return path_none;

this adds 2 access, 1 lstat, 1 open, 1 read, 1 close to _every_ path we check. Is it worth the cost?

Show 31 quoted lines
>
>         dtype = DTYPE(de);
> diff --git a/t/t7508-status.sh b/t/t7508-status.sh
> index c987b5e..2bd7ef1 100755
> --- a/t/t7508-status.sh
> +++ b/t/t7508-status.sh
> @@ -198,6 +198,13 @@ test_expect_success 'status -s' '
>
>  '
>
> +test_expect_success 'status -s with non-standard $GIT_DIR' '
> +       mv .git .foo &&
> +       GIT_DIR=.foo git status -s >output &&
> +       test_cmp expect output &&
> +       mv .foo .git
> +'
> +
>  test_expect_success 'status with gitignore' '
>         {
>                 echo ".gitignore" &&
> --
> 1.8.5-386-gb78cb96
>
>
> --
> Dennis Kaarsemaker <dennis@kaarsemaker.net>
> http://twitter.com/seveas
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Duy
Previous: Dennis KaarsemakerNext: Thomas Rast
Message 5 of 17 in “GIT_DIR not auto ignored”
  1. Ingy dot NetDec 1, 2013
  2. Dennis KaarsemakerDec 1, 2013
  3. Dennis KaarsemakerDec 1, 2013
  4. path_treatment: also ignore $GIT_DIR if it's not .gitDennis Kaarsemaker, Dec 1, 2013
  5. Duy NguyenDec 1, 2013
  6. Thomas RastDec 1, 2013
  7. Dennis KaarsemakerDec 1, 2013
  8. Duy NguyenDec 2, 2013
  9. Dennis KaarsemakerDec 2, 2013
  10. Duy NguyenDec 2, 2013
  11. Dennis KaarsemakerDec 2, 2013
  12. Duy NguyenDec 2, 2013
  13. Eric SunshineDec 2, 2013
  14. Karsten BleesDec 3, 2013
  15. Junio C HamanoDec 3, 2013
  16. Karsten BleesDec 3, 2013
  17. Jonathan NiederDec 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.