{"thread":{"id":"1335","subject":"Re: [RFC] extending git-ls-files --exclude.","startedAt":"2005-07-25T06:41:40Z","lastAt":"2005-07-25T19:56:01Z","messageCount":3,"participants":["Marco Costalba","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"6425","messageId":"20050725064140.95259.qmail@web26304.mail.ukl.yahoo.com","threadId":"1335","inReplyTo":null,"subject":"Re: [RFC] extending git-ls-files --exclude.","fromName":"Marco Costalba","fromEmail":"mcostalba@yahoo.it","sentAt":"2005-07-25T06:41:40Z","receivedAt":"2005-07-25T06:41:40Z","isPatch":false,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"Junio C Hamano wrote:\n\n\n>The list of patterns that is in effect at a given time is\n>built and ordered in the following way:\n>\n> * --exclude=<pattern> and lines read from --exclude-from=<file>\n>   come at the beginning of the list of patterns, in the order\n>   given on the command line.  Patterns that come from the file\n>   specified with --exclude-from are ordered in the same order\n>   as they appear in the file.\n>\n> * When --exclude-per-directory=<name> is specified, upon\n>   entering a directory that has such a file, its contents are\n>   appended at the end of the current \"list of patterns\".  They\n>   are popped off when leaving the directory.\n>\n\nAre really necessary to have both --exclude-from=<file> and \n--exclude-per-directory=<name> ?\n\nPeraphs, if the file name of excluded list is the same for each directory, \ne.g. .gitignore or something similar, instead of --exclude-per-directory\nwe can use a concept of file validity 'scope' and just use --exclude-from=<file>.\nIf entering in a directory <file> is found its contents are appended and \nremoved when leaving directory. A bad analogy can be with the use of \nrecursive Makefile.\n\n>\n>A pattern specified on the command line with --exclude or read\n>from the file specified with --exclude-from is relative to the\n>top of the directory tree.  A pattern read from a file specified\n>by --exclude-per-directory is relative to the directory that the\n>pattern file appears in.\n>\n\nIf we use the 'scope' logic we can just prepend path when adding entries\nand serach with with FNM_PATHNAME flag.\n\n> - if it does not contain a slash '/', it is a shell glob\n>   pattern and used to match against the filename without\n>   leading directories (i.e. the same way as the current\n>   implementation).\n>\n> - otherwise, it is a shell glob pattern, suitable for\n>   consumption by fnmatch(3) with FNM_PATHNAME flag.  I.e. a\n>   slash in the pattern must match a slash in the pathname.\n>   \"Documentation/*.html\" matches \"Documentation/git.html\" but\n>   not \"ppc/ppc.html\".  As a natural exception, \"/*.c\" matches\n>   \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n>\n\nSame comment as above, if prepending path when adding per \ndirectory contents we can simplify to always use FNM_PATHNAME flag.\n\nWe don't have even to special case base directory global\nscope <file> if we use realtive paths so that we prepend its contents \nwith ./ and we have what we expect.\n\nI am sorry to not be able to send a patch, better explaining what \nproposed but I am just leaving today and I will be off line\nfor a couple of weeks.\n\n\nMarco\n\n\n__________________________________________________\nDo You Yahoo!?\nTired of spam?  Yahoo! Mail has the best spam protection around \nhttp://mail.yahoo.com \n"},{"id":"6426","messageId":"7vek9ns5ly.fsf@assigned-by-dhcp.cox.net","threadId":"1335","inReplyTo":"20050725064140.95259.qmail@web26304.mail.ukl.yahoo.com","subject":"Re: [RFC] extending git-ls-files --exclude.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-25T07:32:41Z","receivedAt":"2005-07-25T07:32:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marco Costalba <mcostalba@yahoo.it> writes:\n\n> Are really necessary to have both --exclude-from=<file> and \n> --exclude-per-directory=<name> ?\n>\n> Peraphs, if the file name of excluded list is the same for each directory, \n> e.g. .gitignore or something similar, instead of --exclude-per-directory\n> we can use a concept of file validity 'scope' and just use --exclude-from=<file>.\n> If entering in a directory <file> is found its contents are appended and \n> removed when leaving directory. A bad analogy can be with the use of \n> recursive Makefile.\n\nPasky wants to have one of the files in ~/.git-something if I\nunderstand correctly.  I did not want to remove --exclude-from\nfor that reason.\n\n> If we use the 'scope' logic we can just prepend path when\n> adding entries and serach with with FNM_PATHNAME flag.\n\nAnd I wanted for people's script and existing ignore files to\ncontinue to work.\n\n> Same comment as above, if prepending path when adding per \n> directory contents we can simplify to always use FNM_PATHNAME flag.\n\nYes, but that means you need to always prepend the current\ndirectory being looked at to get the original behaviour.  The\nway it was originally done without FNM_PATHNAME was far easier\nto read, at least for me.\n"},{"id":"6436","messageId":"7v1x5mmzhq.fsf@assigned-by-dhcp.cox.net","threadId":"1335","inReplyTo":"20050725064140.95259.qmail@web26304.mail.ukl.yahoo.com","subject":"Re: [RFC] extending git-ls-files --exclude.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-25T19:56:01Z","receivedAt":"2005-07-25T19:56:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marco Costalba <mcostalba@yahoo.it> writes:\n\n> Peraphs, if the file name of excluded list is the same for each directory, \n> e.g. .gitignore or something similar, instead of --exclude-per-directory\n> we can use a concept of file validity 'scope' and just use --exclude-from=<file>.\n> If entering in a directory <file> is found its contents are appended and \n> removed when leaving directory. A bad analogy can be with the use of \n> recursive Makefile.\n\nI do not know if you noticed it, but the patch already have the\nconcept of \"scope\".  If a pattern has a slash '/' it is scoped\nto the named directory by using FNM_PATHNAME.  \"The named\ndirectory\" for command line --exclude and --exclude-from are\nrelative to the project top while it is relative to the\ndirectory the file being used is in for --exclude-per-directory\ncase.\n\n> If we use the 'scope' logic we can just prepend path when adding entries\n> and serach with with FNM_PATHNAME flag.\n\nYou suggest to always use FNM_PATHNAME by adjusting the pattern\nby prefixing the scope.  While that can theoretically be made to\nwork just as the posted patch does, you need to realize it is a\nlot more cumbersome to deal with metacharacters in pathnames\nyour way.  If the prefix you need to add (because you are now\nlooking at a path for that directory which has a funny name) is\n\"foo*bar\", you need to add \"foo\\*bar\" to the pattern in order to\nmake sure that the asterisk is not used to match anything other\nthan a literal asterisk, for example.\n\nYou could argue that nobody should use funny characters in\npathnames, and you could further argue that current Porcelains\ndo not handle certain characters in pathnames anyway so why\nbother.  But ls-files being core, which is \"the funny filesystem\nlayer to build SCM on\", I would like to be careful not to be\nunnecessarily restrictive.\n"}]}