threads / discuss / 708

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

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

## tl;dr

11 messages between May 25, 2005 and May 26, 2005.

replies: 10people: 3as markdown or json

Junio C Hamano· May 25, 2005, 00:12 UTC · lore

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· May 25, 2005, 00:24 UTC · re: Junio C Hamano · lore
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· May 25, 2005, 00:32 UTC · re: Linus Torvalds · lore
>>>>> "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· May 25, 2005, 00:44 UTC · re: Junio C Hamano · lore

[PATCH] Allow dot files in ls-files as well.

>>>>> "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· May 25, 2005, 00:54 UTC · re: Junio C Hamano · lore

Re: [PATCH] Allow dot files in ls-files as well.

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· May 25, 2005, 01:20 UTC · re: Linus Torvalds · lore

[PATCH] Allow dot files in ls-files as well (take #2).

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;
Linus Torvalds· May 25, 2005, 00:52 UTC · re: Junio C Hamano · lore
On Tue, 24 May 2005, Junio C Hamano wrote:
Show 7 quoted lines
> >>>>> "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
Junio C Hamano· May 25, 2005, 01:11 UTC · re: Linus Torvalds · lore
>>>>> "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";
Petr Baudis· May 26, 2005, 08:37 UTC · re: Junio C Hamano · lore

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...

Show 10 quoted lines
> >>>>> "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· May 26, 2005, 09:02 UTC · re: Petr Baudis · lore
>>>>> "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.

← back to recent threads