git-update-cache: allow dot-files
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)
+{
+ /*
Quoted 3 lines · Junio C Hamano
Linus, I think this is wrong.
GIT_DIRcould 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
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"LT" == Linus Torvalds <[email protected]> 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.
PATCH 1/1 Allow dot files in ls-files as well.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"JCH" == Junio C Hamano <[email protected]> writes:
"LT" == Linus Torvalds <[email protected]> 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.
---
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)
ls-files.c +3 -1
@@ -136,7 +136,9 @@ static void read_directory(const char *pwhile ((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 ;
Re: [PATCH] Allow dot files in ls-files as well.
Quoted 4 lines · Junio C Hamano
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
Re: [PATCH] Allow dot files in ls-files as well.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"LT" == Linus Torvalds <[email protected]> writes:
LT> You really _do_ want to strip out the ".git" file.
Yes I do, but not probably hardcoded ".git".
PATCH 1/1 Allow dot files in ls-files as well (take #2).
In reply to Linus TorvaldsThis attempts to match "the directory '.git' anywhere in the tree is ignored" approach taken in update-cache.
---
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)
ls-files.c +4 -1
@@ -136,7 +136,10 @@ static void read_directory(const char *pwhile ((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 ;
Quoted 7 lines · Junio C Hamano
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"LT" == Linus Torvalds <[email protected]> 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_DIRset 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
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"LT" == Linus Torvalds <[email protected]> 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";
Dear diary, on Wed, May 25, 2005 at 03:11:42AM CEST, I got a letter where Junio C Hamano <[email protected]> told me that...
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"LT" == Linus Torvalds <[email protected]> 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 forbidGIT_DIRto be set to anything other than whatends 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 ?
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"PB" == Petr Baudis <[email protected]> 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.