# Re: git-update-cache: allow dot-files

11 messages from 2005-05-25 to 2005-05-26. Participants: Junio C Hamano, Linus Torvalds, Petr Baudis.
Thread: https://gitlist.dev/t/708

## Junio C Hamano, 2005-05-25 00:12

Subject: Re: git-update-cache: allow dot-files
Message-ID: <7vhdgstb7x.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vhdgstb7x.fsf%40assigned-by-dhcp.cox.net

```
Linus, I think this is wrong.  GIT_DIR could be something other
than ".git".  I'd rather allow everything other than . and .. in
the core layer, and have Porcelain layer ignore-paths logic to
deal with "^.git/" (only when GIT_DIR is .git; otherwise
ignore-path configuration file for that particular tree needs to
say what to ignore).

    git-update-cache: allow dot-files

    diff --git a/update-cache.c b/update-cache.c
    --- a/update-cache.c
    +++ b/update-cache.c
    @@ -238,13 +238,42 @@ static int refresh_cache(void)

     /*
      * We fundamentally don't like some paths: we don't want
    - * dot or dot-dot anywhere, and in fact, we don't even want
    - * any other dot-files (.git or anything else). They
    - * are hidden, for chist sake.
    + * dot or dot-dot anywhere, and for obvious reasons don't
    + * want to recurse into ".git" either.
      *
      * Also, we don't want double slashes or slashes at the
      * end that can make pathnames ambiguous.
      */
    +static int verify_dotfile(const char *rest)
    +{
    +	/*


```

## Linus Torvalds, 2005-05-25 00:24

Subject: Re: git-update-cache: allow dot-files
Message-ID: <Pine.LNX.4.58.0505241723060.2307@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0505241723060.2307%40ppc970.osdl.org
In-Reply-To: <7vhdgstb7x.fsf@assigned-by-dhcp.cox.net>

```


On Tue, 24 May 2005, Junio C Hamano wrote:
>
> Linus, I think this is wrong.  GIT_DIR could be something other
> than ".git".

I considered it, but it's so much easier to allow things later than deny 
them, that I preferred being anal about it.

			Linus

```

## Junio C Hamano, 2005-05-25 00:32

Subject: Re: git-update-cache: allow dot-files
Message-ID: <7v8y24taai.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v8y24taai.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.58.0505241723060.2307@ppc970.osdl.org>

```
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

LT> I considered it, but it's so much easier to allow things
LT> later than deny them, that I preferred being anal about it.

That is not the point.  GIT_DIR set to "GIT" would happily suck
index file in.  You are not being anal enough.


```

## Junio C Hamano, 2005-05-25 00:44

Subject: [PATCH] Allow dot files in ls-files as well.
Message-ID: <7v1x7wt9qm.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v1x7wt9qm.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <7v8y24taai.fsf@assigned-by-dhcp.cox.net>

```
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:

>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> I considered it, but it's so much easier to allow things
LT> later than deny them, that I preferred being anal about it.

JCH> That is not the point.  GIT_DIR set to "GIT" would happily suck
JCH> index file in.  You are not being anal enough.

... which makes me feel that, since you cannot be anal enough
anyway, it would be more consistent not to be more restrictive
than necessary (the user has every right to screw himself
anyway).

No matter what you end up doing, you would need something like
this as well (I am not screening .git here but that should be
easy for you to add).

------------
Allow dot files in ls-files as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
cd /opt/packrat/playpen/public/in-place/git/git.junio/
PATH=.:$PATH jit-diff 1: ls-files.c
# - linus: git-update-cache: allow dot-files
# + (working tree)
diff --git a/ls-files.c b/ls-files.c
--- a/ls-files.c
+++ b/ls-files.c
@@ -136,7 +136,9 @@ static void read_directory(const char *p
 		while ((de = readdir(dir)) != NULL) {
 			int len;
 
-			if (de->d_name[0] == '.')
+			if (de->d_name[0] == '.' &&
+			    (de->d_name[1] == 0 ||
+			     (de->d_name[1] == '.' && de->d_name[2] == 0)))
 				continue;
 			if (excluded(de->d_name) != show_ignored)
 				continue;



```

## Linus Torvalds, 2005-05-25 00:52

Subject: Re: git-update-cache: allow dot-files
Message-ID: <Pine.LNX.4.58.0505241748520.2307@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0505241748520.2307%40ppc970.osdl.org
In-Reply-To: <7v8y24taai.fsf@assigned-by-dhcp.cox.net>

```


On Tue, 24 May 2005, Junio C Hamano wrote:
> >>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
> 
> LT> I considered it, but it's so much easier to allow things
> LT> later than deny them, that I preferred being anal about it.
> 
> That is not the point.  GIT_DIR set to "GIT" would happily suck
> index file in.  You are not being anal enough.

Heh. There's a difference between being anal, and allowing people to shoot 
themselves in the foot.

I'll happily allow people who _try_ to do stupid things to do them ;)

It's the

	find . -type f | cut -d/ -f2- | xargs git-update-cache --add --

kinds of "unintentionally stupid" scripts I want to avoid (and the reason
I do that is because that's basically _exactly_ the script I used when
testing something ;)

		Linus

```

## Linus Torvalds, 2005-05-25 00:54

Subject: Re: [PATCH] Allow dot files in ls-files as well.
Message-ID: <Pine.LNX.4.58.0505241753300.2307@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0505241753300.2307%40ppc970.osdl.org
In-Reply-To: <7v1x7wt9qm.fsf_-_@assigned-by-dhcp.cox.net>

```


On Tue, 24 May 2005, Junio C Hamano wrote:
> 
> No matter what you end up doing, you would need something like
> this as well (I am not screening .git here but that should be
> easy for you to add).

Ehh, this will do bad things for "git-show-files --others", no?

You really _do_ want to strip out the ".git" file.

		Linus

```

## Junio C Hamano, 2005-05-25 01:06

Subject: Re: [PATCH] Allow dot files in ls-files as well.
Message-ID: <7v8y24ru51.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v8y24ru51.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.58.0505241753300.2307@ppc970.osdl.org>

```
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

LT> You really _do_ want to strip out the ".git" file.

Yes I do, but not probably hardcoded ".git".


```

## Junio C Hamano, 2005-05-25 01:11

Subject: Re: git-update-cache: allow dot-files
Message-ID: <7v3bscrtwx.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v3bscrtwx.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.58.0505241748520.2307@ppc970.osdl.org>

```
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

LT> Heh. There's a difference between being anal, and allowing people to shoot 
LT> themselves in the foot.

How about we do something like this:

 (1) we keep hardcoded .git refusing as you did;
 (2) we forbid GIT_DIR to be set to anything other than what
     ends with "/.git", unless it is literally ".git";



```

## Junio C Hamano, 2005-05-25 01:20

Subject: [PATCH] Allow dot files in ls-files as well (take #2).
Message-ID: <7vwtpoqeyf.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vwtpoqeyf.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.58.0505241753300.2307@ppc970.osdl.org>

```
This attempts to match "the directory '.git' anywhere in the
tree is ignored" approach taken in update-cache.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
cd /opt/packrat/playpen/public/in-place/git/git.junio/
PATH=.:$PATH jit-diff : ls-files.c
# - linus: git-update-cache: allow dot-files
# + (working tree)
diff --git a/ls-files.c b/ls-files.c
--- a/ls-files.c
+++ b/ls-files.c
@@ -136,7 +136,10 @@ static void read_directory(const char *p
 		while ((de = readdir(dir)) != NULL) {
 			int len;
 
-			if (de->d_name[0] == '.')
+			if ((de->d_name[0] == '.') &&
+			    (de->d_name[1] == 0 ||
+			     !strcmp(de->d_name + 1, ".") ||
+			     !strcmp(de->d_name + 1, "git")))
 				continue;
 			if (excluded(de->d_name) != show_ignored)
 				continue;




```

## Petr Baudis, 2005-05-26 08:37

Subject: Re: git-update-cache: allow dot-files
Message-ID: <20050526083745.GD22262@pasky.ji.cz>
URL: https://gitlist.dev/e/20050526083745.GD22262%40pasky.ji.cz
In-Reply-To: <7v3bscrtwx.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Wed, May 25, 2005 at 03:11:42AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> >>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
> 
> LT> Heh. There's a difference between being anal, and allowing people to shoot 
> LT> themselves in the foot.
> 
> How about we do something like this:
> 
>  (1) we keep hardcoded .git refusing as you did;
>  (2) we forbid GIT_DIR to be set to anything other than what
>      ends with "/.git", unless it is literally ".git";

That doesn't make any sense. When I'm working on kernel.org, why
would you prohibit me to set GIT_DIR to /pub/scm/cogito/cogito.git ?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Junio C Hamano, 2005-05-26 09:02

Subject: Re: git-update-cache: allow dot-files
Message-ID: <7vd5ree4w1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5ree4w1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20050526083745.GD22262@pasky.ji.cz>

```
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB> That doesn't make any sense. When I'm working on kernel.org, why
PB> would you prohibit me to set GIT_DIR to /pub/scm/cogito/cogito.git ?

What you say makes perfect sense, but avoiding hardcoded ".git/"
does not make any sense either in that situation.  

Alternative suggestions welcome.


```
