{"thread":{"id":"3139","subject":"git-ls-files in subdirectories ignore higher-up .gitignore","startedAt":"2006-01-24T17:59:30Z","lastAt":"2006-02-10T04:44:31Z","messageCount":6,"participants":["Pavel Roskin","Junio C Hamano","Sam Ravnborg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15088","messageId":"1138125570.24415.11.camel@dv","threadId":"3139","inReplyTo":null,"subject":"git-ls-files in subdirectories ignore higher-up .gitignore","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-01-24T17:59:30Z","receivedAt":"2006-01-24T17:59:30Z","isPatch":false,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\ngit-ls-files appears to behave in a way that may be unexpected to the\nusers.  When run in a subdirectory, git-ls-files never reads .gitignore\nor whatever is specified by --exclude-per-directory in the parent\ndirectories.\n\nThis can be demonstrated in git's own repository:\n\n$ touch t/test.o\n$ git-ls-files --others --exclude-per-directory=.gitignore\n$ cd t\n$ git-ls-files --others --exclude-per-directory=.gitignore\ntest.o\n$\n\nBefore I attempt to fix it, I'd like to make sure it's a bug, not a\nfeature.\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"15095","messageId":"7vhd7t3vqf.fsf@assigned-by-dhcp.cox.net","threadId":"3139","inReplyTo":"1138125570.24415.11.camel@dv","subject":"Re: git-ls-files in subdirectories ignore higher-up .gitignore","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-25T02:08:24Z","receivedAt":"2006-01-25T02:08:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Roskin <proski@gnu.org> writes:\n\n> This can be demonstrated in git's own repository:\n>\n> $ touch t/test.o\n> $ git-ls-files --others --exclude-per-directory=.gitignore\n> $ cd t\n> $ git-ls-files --others --exclude-per-directory=.gitignore\n> test.o\n> $\n>\n> Before I attempt to fix it, I'd like to make sure it's a bug, not a\n> feature.\n\nI am not sure if that is a bug or a feature, but you are right.\nWe do not bother to go uplevel and look for .gitignore in the\ncurrent code.\n\nIt would probably be a welcome addition if your fix made these\ntwo sequences work similarly modulo leading paths from the\ncommand output.  I think it is natural to expect they are moral\nequivalents:\n\n\t(Sequence 1)\n\t$ touch t/test.o t/garbage\n        $ git-ls-files -o --exclude-per-directory=.gitignore t/\n\n\t(Sequence 2)\n\t$ touch t/test.o t/garbage\n        $ cd t\n        $ git-ls-files -o --exclude-per-directory=.gitignore\n"},{"id":"15103","messageId":"20060125061140.GA8408@mars.ravnborg.org","threadId":"3139","inReplyTo":"1138125570.24415.11.camel@dv","subject":"Re: git-ls-files in subdirectories ignore higher-up .gitignore","fromName":"Sam Ravnborg","fromEmail":"sam@ravnborg.org","sentAt":"2006-01-25T06:11:40Z","receivedAt":"2006-01-25T06:11:40Z","isPatch":false,"sender":{"key":"sam@ravnborg.org","avatar":"https://gravatar.com/avatar/168a912606ed0742d840bb365e3cc21db390c36531a58341dc7a069cc1f15f62?d=mp&s=160"},"body":"On Tue, Jan 24, 2006 at 12:59:30PM -0500, Pavel Roskin wrote:\n> Hello!\n> \n> git-ls-files appears to behave in a way that may be unexpected to the\n> users.  When run in a subdirectory, git-ls-files never reads .gitignore\n> or whatever is specified by --exclude-per-directory in the parent\n> directories.\n> \n> This can be demonstrated in git's own repository:\n> \n> $ touch t/test.o\n> $ git-ls-files --others --exclude-per-directory=.gitignore\n> $ cd t\n> $ git-ls-files --others --exclude-per-directory=.gitignore\n> test.o\n> $\n> \n> Before I attempt to fix it, I'd like to make sure it's a bug, not a\n> feature.\n\nI for one consider it a bug.\nI expect exactly same output if I do\ngit ls-files t/\nor\ncd t; git ls-files\n\nVery usefull when I limit grep to some part of the kernel tree for\nexample.\n\n\tSam\n"},{"id":"15770","messageId":"7vmzh1eykq.fsf_-_@assigned-by-dhcp.cox.net","threadId":"3139","inReplyTo":"20060125061140.GA8408@mars.ravnborg.org","subject":"[PATCH] ls-files: honour per-directory ignore file from higher directories.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-09T08:16:53Z","receivedAt":"2006-02-09T08:16:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When git-ls-files -o --exclude-per-directory=.gitignore is run\nfrom a subdirectory, it did not read from .gitignore from its\nparent directory.  Reading from them makes output from these two\ncommands consistent:\n\n    $ git ls-files -o --exclude-per-directory=.gitignore Documentation\n    $ cd Documentation &&\n      git ls-files -o --exclude-per-directory=.gitignore\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * If there are positive feedbacks on this one, I consider it\n   a safe enough candidate to be included in 1.2.0 release.\n\n ls-files.c |   22 +++++++++++++++++++++-\n 1 files changed, 21 insertions(+), 1 deletions(-)\n\n701ca744e386c2429ca44072ea987bbb4bdac7ce\ndiff --git a/ls-files.c b/ls-files.c\nindex 6af3b09..7024cf1 100644\n--- a/ls-files.c\n+++ b/ls-files.c\n@@ -474,8 +474,28 @@ static void show_files(void)\n \t\tconst char *path = \".\", *base = \"\";\n \t\tint baselen = prefix_len;\n \n-\t\tif (baselen)\n+\t\tif (baselen) {\n \t\t\tpath = base = prefix;\n+\t\t\tif (exclude_per_dir) {\n+\t\t\t\tchar *p, *pp = xmalloc(baselen+1);\n+\t\t\t\tmemcpy(pp, prefix, baselen+1);\n+\t\t\t\tp = pp;\n+\t\t\t\twhile (1) {\n+\t\t\t\t\tchar save = *p;\n+\t\t\t\t\t*p = 0;\n+\t\t\t\t\tpush_exclude_per_directory(pp, p-pp);\n+\t\t\t\t\t*p++ = save;\n+\t\t\t\t\tif (!save)\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t\tp = strchr(p, '/');\n+\t\t\t\t\tif (p)\n+\t\t\t\t\t\tp++;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tp = pp + baselen;\n+\t\t\t\t}\n+\t\t\t\tfree(pp);\n+\t\t\t}\n+\t\t}\n \t\tread_directory(path, base, baselen);\n \t\tqsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);\n \t\tif (show_others)\n-- \n1.1.6.gbb042\n"},{"id":"15838","messageId":"1139542730.23725.3.camel@dv","threadId":"3139","inReplyTo":"7vmzh1eykq.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] ls-files: honour per-directory ignore file from higher directories.","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-02-10T03:38:50Z","receivedAt":"2006-02-10T03:38:50Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello, Junio!\n\nOn Thu, 2006-02-09 at 00:16 -0800, Junio C Hamano wrote:\n> When git-ls-files -o --exclude-per-directory=.gitignore is run\n> from a subdirectory, it did not read from .gitignore from its\n> parent directory.  Reading from them makes output from these two\n> commands consistent:\n\nYou beat me at that.  Thank you!\n\nWith this patch, the simplified version of cg-clean passes the cogito\ntestsuite.  That's where the original bug was caught.\n\n>  * If there are positive feedbacks on this one, I consider it\n>    a safe enough candidate to be included in 1.2.0 release.\n\nYes, it would be nice to see it released.\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"15842","messageId":"7vhd77zuts.fsf@assigned-by-dhcp.cox.net","threadId":"3139","inReplyTo":"1139542730.23725.3.camel@dv","subject":"Re: [PATCH] ls-files: honour per-directory ignore file from higher directories.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T04:44:31Z","receivedAt":"2006-02-10T04:44:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Roskin <proski@gnu.org> writes:\n\n> With this patch, the simplified version of cg-clean passes the cogito\n> testsuite.  That's where the original bug was caught.\n\nThanks for testing it.\n"}]}