{"thread":{"id":"10855","subject":"git-clean won't read global ignore","startedAt":"2007-11-13T21:49:00Z","lastAt":"2007-11-15T17:50:22Z","messageCount":16,"participants":["shunichi fuji","Pierre Habouzit","Junio C Hamano","Andreas Ericsson","Johannes Schindelin","Miles Bader","Jeff King","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"59747","messageId":"30046e3b0711131349h51d253d5n4e5649bde36dc36f@mail.gmail.com","threadId":"10855","inReplyTo":null,"subject":"git-clean won't read global ignore","fromName":"shunichi fuji","fromEmail":"palglowr@gmail.com","sentAt":"2007-11-13T21:49:00Z","receivedAt":"2007-11-13T21:49:00Z","isPatch":false,"sender":{"key":"palglowr@gmail.com","avatar":null},"body":"hi, i setup git to use with eclipse through global excludesfile config.\ngit-status report just ignore files, but git-clean deleted ignore files.\n\n----\n$ git-config -l\ncore.excludesfile=/home/pal/.gitignore\n\n$ cat /home/pal/.gitignore\n# ignore for eclipse\n.project\n.cproject\n\n $ git-status\n# On branch master\nnothing to commit (working directory clean)\n\n$ git-clean\nRemoving .project\n"},{"id":"59763","messageId":"20071113225057.GB22836@artemis.corp","threadId":"10855","inReplyTo":"30046e3b0711131349h51d253d5n4e5649bde36dc36f@mail.gmail.com","subject":"Re: git-clean won't read global ignore","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-13T22:50:57Z","receivedAt":"2007-11-13T22:50:57Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Tue, Nov 13, 2007 at 09:49:00PM +0000, shunichi fuji wrote:\n> hi, i setup git to use with eclipse through global excludesfile config.\n> git-status report just ignore files, but git-clean deleted ignore files.\n> \n> ----\n> $ git-config -l\n> core.excludesfile=/home/pal/.gitignore\n> \n> $ cat /home/pal/.gitignore\n> # ignore for eclipse\n> ..project\n> ..cproject\n> \n>  $ git-status\n> # On branch master\n> nothing to commit (working directory clean)\n> \n> $ git-clean\n> Removing .project\n\n.project is not ..project right ?\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"59822","messageId":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"20071113225057.GB22836@artemis.corp","subject":"Re: git-clean won't read global ignore","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-14T08:05:00Z","receivedAt":"2007-11-14T08:05:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I think the problem is core.excludesfile is too new to be\nnoticed by anything other than git-add and git-status.\n\n * git-add and git-status know about it because they call\n   add_excludes_from_file() directly with their own notion of\n   which standard set of ignore files to use.  This is just a\n   stupid duplication of code that need to be updated every time\n   the definition of the standard set of ignore files is\n   changed.\n\n * git-ls-files does not notice any of the \"ignore\" files by\n   default, as it predates the standardized set of ignore\n   files.  The calling scripts established the convention to use\n   .git/info/exclude, .gitignore in each file, and later\n   core.excludesfile.\n\n * git-read-tree takes --exclude-per-directory=<gitignore>,\n   not because the flexibility was needed.  Again, this was\n   because the option predates the standardization of the ignore\n   files.\n\n * git-merge-recursive uses hardcoded per-directory .gitignore\n   and nothing else.  git-clean (scripted version) does not\n   honor core.* because its call to underlying ls-files does not\n   know about it.  git-clean in C (parked in 'pu') doesn't either.\n\nWe probably could change git-ls-files to use the standard set\nwhen no excludes are specified from the command line, or\nsomething like that, but this will be a change in semantics that\nwould affect the scripts in a subtle way.  I am somewhat\nreluctant to make such a change.\n\nOn the other hand, I think it makes perfect sense to fix\ngit-read-tree, git-merge-recursive and git-clean to follow the\nsame rule as other commands.  I do not think of a valid use case\nto give an exclude-per-directory that is nonstandard to\nread-tree command, outside a \"negative\" test in the t1004 test\nscript.\n\nTo untangle this mess, I think the first step would be something\nlike this (this is against 'maint', as I was in the middle of\nsomething else that is based on 'maint' when I started reading\nthis thread).\n\nThe next step would be to teach read-tree, merge-recursive and\nclean (in C) to use setup_standard_excludes().\n\n---\n\n builtin-add.c |   22 ++--------------------\n cache.h       |    1 +\n config.c      |    7 +++++++\n dir.c         |   12 ++++++++++++\n dir.h         |    1 +\n environment.c |    1 +\n wt-status.c   |   15 +--------------\n 7 files changed, 25 insertions(+), 34 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 373f87f..850e1c2 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -17,7 +17,6 @@ static const char builtin_add_usage[] =\n \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] <filepattern>...\";\n \n static int take_worktree_changes;\n-static const char *excludes_file;\n \n static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)\n {\n@@ -57,12 +56,7 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec,\n \tmemset(dir, 0, sizeof(*dir));\n \tif (!ignored_too) {\n \t\tdir->collect_ignored = 1;\n-\t\tdir->exclude_per_dir = \".gitignore\";\n-\t\tpath = git_path(\"info/exclude\");\n-\t\tif (!access(path, R_OK))\n-\t\t\tadd_excludes_from_file(dir, path);\n-\t\tif (excludes_file != NULL && !access(excludes_file, R_OK))\n-\t\t\tadd_excludes_from_file(dir, excludes_file);\n+\t\tsetup_standard_excludes(dir);\n \t}\n \n \t/*\n@@ -144,18 +138,6 @@ static void refresh(int verbose, const char **pathspec)\n         free(seen);\n }\n \n-static int git_add_config(const char *var, const char *value)\n-{\n-\tif (!strcmp(var, \"core.excludesfile\")) {\n-\t\tif (!value)\n-\t\t\tdie(\"core.excludesfile without value\");\n-\t\texcludes_file = xstrdup(value);\n-\t\treturn 0;\n-\t}\n-\n-\treturn git_default_config(var, value);\n-}\n-\n static struct lock_file lock_file;\n \n static const char ignore_error[] =\n@@ -183,7 +165,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\texit(1);\n \t}\n \n-\tgit_config(git_add_config);\n+\tgit_config(git_default_config);\n \n \tnewfd = hold_locked_index(&lock_file, 1);\n \ndiff --git a/cache.h b/cache.h\nindex fc195bc..ecd809d 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -571,6 +571,7 @@ extern int pager_in_use;\n extern int pager_use_color;\n \n extern char *editor_program;\n+extern char *excludes_file;\n \n /* base85 */\n int decode_85(char *dst, const char *line, int linelen);\ndiff --git a/config.c b/config.c\nindex dc3148d..56e99fc 100644\n--- a/config.c\n+++ b/config.c\n@@ -431,6 +431,13 @@ int git_default_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"core.excludesfile\")) {\n+\t\tif (!value)\n+\t\t\tdie(\"core.excludesfile without value\");\n+\t\texcludes_file = xstrdup(value);\n+\t\treturn 0;\n+\t}\n+\n \t/* Add other config variables here and to Documentation/config.txt. */\n \treturn 0;\n }\ndiff --git a/dir.c b/dir.c\nindex f843c4d..73a39ed 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -709,3 +709,15 @@ int is_inside_dir(const char *dir)\n \tchar buffer[PATH_MAX];\n \treturn get_relative_cwd(buffer, sizeof(buffer), dir) != NULL;\n }\n+\n+void setup_standard_excludes(struct dir_struct *dir)\n+{\n+\tconst char *path;\n+\n+\tdir->exclude_per_dir = \".gitignore\";\n+\tpath = git_path(\"info/exclude\");\n+\tif (!access(path, R_OK))\n+\t\tadd_excludes_from_file(dir, path);\n+\tif (excludes_file && !access(excludes_file, R_OK))\n+\t\tadd_excludes_from_file(dir, excludes_file);\n+}\ndiff --git a/dir.h b/dir.h\nindex f55a87b..a5f4237 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -63,5 +63,6 @@ extern struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna\n \n extern char *get_relative_cwd(char *buffer, int size, const char *dir);\n extern int is_inside_dir(const char *dir);\n+extern void setup_standard_excludes(struct dir_struct *dir);\n \n #endif\ndiff --git a/environment.c b/environment.c\nindex b5a6c69..1dab72e 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -34,6 +34,7 @@ char *pager_program;\n int pager_in_use;\n int pager_use_color = 1;\n char *editor_program;\n+char *excludes_file;\n int auto_crlf = 0;\t/* 1: both ways, -1: only when adding git objects */\n \n /* This is set by setup_git_dir_gently() and/or git_default_config() */\ndiff --git a/wt-status.c b/wt-status.c\nindex 10ce6ee..58dd716 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -22,7 +22,6 @@ static const char use_add_rm_msg[] =\n \"use \\\"git add/rm <file>...\\\" to update what will be committed\";\n static const char use_add_to_include_msg[] =\n \"use \\\"git add <file>...\\\" to include in what will be committed\";\n-static const char *excludes_file;\n \n static int parse_status_slot(const char *var, int offset)\n {\n@@ -247,22 +246,16 @@ static void wt_status_print_changed(struct wt_status *s)\n static void wt_status_print_untracked(struct wt_status *s)\n {\n \tstruct dir_struct dir;\n-\tconst char *x;\n \tint i;\n \tint shown_header = 0;\n \n \tmemset(&dir, 0, sizeof(dir));\n \n-\tdir.exclude_per_dir = \".gitignore\";\n \tif (!s->untracked) {\n \t\tdir.show_other_directories = 1;\n \t\tdir.hide_empty_directories = 1;\n \t}\n-\tx = git_path(\"info/exclude\");\n-\tif (file_exists(x))\n-\t\tadd_excludes_from_file(&dir, x);\n-\tif (excludes_file && file_exists(excludes_file))\n-\t\tadd_excludes_from_file(&dir, excludes_file);\n+\tsetup_standard_excludes(&dir);\n \n \tread_directory(&dir, \".\", \"\", 0, NULL);\n \tfor(i = 0; i < dir.nr; i++) {\n@@ -360,11 +353,5 @@ int git_status_config(const char *k, const char *v)\n \t\tint slot = parse_status_slot(k, 13);\n \t\tcolor_parse(v, k, wt_status_colors[slot]);\n \t}\n-\tif (!strcmp(k, \"core.excludesfile\")) {\n-\t\tif (!v)\n-\t\t\tdie(\"core.excludesfile without value\");\n-\t\texcludes_file = xstrdup(v);\n-\t\treturn 0;\n-\t}\n \treturn git_default_config(k, v);\n }\n"},{"id":"59824","messageId":"473AB508.4090109@op5.se","threadId":"10855","inReplyTo":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","subject":"Re: git-clean won't read global ignore","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-11-14T08:42:48Z","receivedAt":"2007-11-14T08:42:48Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> (this is against 'maint', as I was in the middle of\n> something else that is based on 'maint' when I started reading\n> this thread).\n> \n\nThat's probably not a bad idea, as it really is a bug, and one\nthat can cause data-loss at that.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"59830","messageId":"7vzlxhjj1y.fsf@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"473AB508.4090109@op5.se","subject":"Re: git-clean won't read global ignore","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-14T09:03:05Z","receivedAt":"2007-11-14T09:03:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> Junio C Hamano wrote:\n>> (this is against 'maint', as I was in the middle of\n>> something else that is based on 'maint' when I started reading\n>> this thread).\n>>\n>\n> That's probably not a bad idea, as it really is a bug, and one\n> that can cause data-loss at that.\n\nI agree that \"git clean\" needs to be fixed in 'maint', but the\nthing is, setup_standard_excludes() approach would not apply to\nanything in 'maint', 'master', nor 'next', and it is more of the\nlonger term thing to go together with the git-clean in C.\n\nThe scripted version needs to be fixed independently in a way\nwith lessor impact, like the patch Shunichi just posted.\n"},{"id":"59856","messageId":"Pine.LNX.4.64.0711141746130.4362@racer.site","threadId":"10855","inReplyTo":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","subject":"Re: git-clean won't read global ignore","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-14T17:46:38Z","receivedAt":"2007-11-14T17:46:38Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Nov 2007, Junio C Hamano wrote:\n\n> To untangle this mess, I think the first step would be something like \n> this (this is against 'maint', as I was in the middle of something else \n> that is based on 'maint' when I started reading this thread).\n> \n> The next step would be to teach read-tree, merge-recursive and clean (in \n> C) to use setup_standard_excludes().\n\nI like it.\n\nCiao,\nDscho\n"},{"id":"59914","messageId":"buo6404gmu7.fsf@dhapc248.dev.necel.com","threadId":"10855","inReplyTo":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","subject":"Re: git-clean won't read global ignore","fromName":"Miles Bader","fromEmail":"miles.bader@necel.com","sentAt":"2007-11-15T04:21:52Z","receivedAt":"2007-11-15T04:21:52Z","isPatch":false,"sender":{"key":"miles.bader@necel.com","avatar":"https://gravatar.com/avatar/be062d4050eb88e04229cbdb60f803e1bd647923a015996c2439e76f23e336a7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> I think the problem is core.excludesfile is too new to be\n> noticed by anything other than git-add and git-status.\n\n\"git-add -i\" _doesn't_ seems to notice it though...\n\n-Miles\n\n-- \n[|nurgle|]  ddt- demonic? so quake will have an evil kinda setting? one that\n            will  make every christian in the world foamm at the mouth?\n[iddt]      nurg, that's the goal\n"},{"id":"59918","messageId":"buoy7d0f7qb.fsf@dhapc248.dev.necel.com","threadId":"10855","inReplyTo":"buo6404gmu7.fsf@dhapc248.dev.necel.com","subject":"Re: git-clean won't read global ignore","fromName":"Miles Bader","fromEmail":"miles.bader@necel.com","sentAt":"2007-11-15T04:33:32Z","receivedAt":"2007-11-15T04:33:32Z","isPatch":false,"sender":{"key":"miles.bader@necel.com","avatar":"https://gravatar.com/avatar/be062d4050eb88e04229cbdb60f803e1bd647923a015996c2439e76f23e336a7?d=mp&s=160"},"body":"Miles Bader <miles.bader@necel.com> writes:\n>> I think the problem is core.excludesfile is too new to be\n>> noticed by anything other than git-add and git-status.\n>\n> \"git-add -i\" _doesn't_ seems to notice it though...\n\nTo clarify:  the \"add untracked\" sub-menu of \"git-add -i\"\n\n-Miles\n-- \nDo not taunt Happy Fun Ball.\n"},{"id":"59933","messageId":"7v4pfo813i.fsf_-_@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Unify the use of standard set of exclude files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-15T06:38:41Z","receivedAt":"2007-11-15T06:38:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> We probably could change git-ls-files to use the standard set\n> when no excludes are specified from the command line, or\n> something like that, but this will be a change in semantics that\n> would affect the scripts in a subtle way.  I am somewhat\n> reluctant to make such a change.\n\nSo here it is.\n\nThis teaches \"git ls-files\" to read the standard set of exclude\nfiles when no exclude patterns nor files is given from the\ncommand line.  We used to error out in such a case.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n builtin-ls-files.c |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-ls-files.c b/builtin-ls-files.c\nindex e0b856f..50dcb89 100644\n--- a/builtin-ls-files.c\n+++ b/builtin-ls-files.c\n@@ -542,11 +542,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\tps_matched = xcalloc(1, num);\n \t}\n \n-\tif (dir.show_ignored && !exc_given) {\n-\t\tfprintf(stderr, \"%s: --ignored needs some exclude pattern\\n\",\n-\t\t\targv[0]);\n-\t\texit(1);\n-\t}\n+\tif (dir.show_ignored && !exc_given)\n+\t\tsetup_standard_excludes(&dir);\n \n \t/* With no flags, we default to showing the cached files */\n \tif (!(show_stage | show_deleted | show_others | show_unmerged |\n"},{"id":"59935","messageId":"20071115070429.GD10185@sigill.intra.peff.net","threadId":"10855","inReplyTo":"7v4pfo813i.fsf_-_@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Unify the use of standard set of exclude files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-15T07:04:30Z","receivedAt":"2007-11-15T07:04:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 14, 2007 at 10:38:41PM -0800, Junio C Hamano wrote:\n\n> This teaches \"git ls-files\" to read the standard set of exclude\n> files when no exclude patterns nor files is given from the\n> command line.  We used to error out in such a case.\n\nIs that really the case, or is this _just_ when we have asked to include\nignored files in the output? Or maybe I am missing something fundamental\nhere.\n\ngit-add--interactive:list_untracked needs something like this, but I\ndon't think your patch will work. We need something more like this (also\non maint because your standard exclude patch is):\n\n-- >8 --\ngit-ls-files: add --exclude-standard\n\nThis provides a way for scripts to get at the new standard exclude\nfunction.\n\n---\ndiff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt\nindex 9e454f0..2ec0c0d 100644\n--- a/Documentation/git-ls-files.txt\n+++ b/Documentation/git-ls-files.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n \t\t[-x <pattern>|--exclude=<pattern>]\n \t\t[-X <file>|--exclude-from=<file>]\n \t\t[--exclude-per-directory=<file>]\n+\t\t[--exclude-standard]\n \t\t[--error-unmatch] [--with-tree=<tree-ish>]\n \t\t[--full-name] [--abbrev] [--] [<file>]\\*\n \n@@ -77,6 +78,10 @@ OPTIONS\n \tread additional exclude patterns that apply only to the\n \tdirectory and its subdirectories in <file>.\n \n+--exclude-standard::\n+\tAdd the standard git exclusions: .git/info/exclude, .gitignore\n+\tin each directory, and the user's global exclusion file.\n+\n --error-unmatch::\n \tIf any <file> does not appear in the index, treat this as an\n \terror (return 1).\ndiff --git a/builtin-ls-files.c b/builtin-ls-files.c\nindex 171d449..da97278 100644\n--- a/builtin-ls-files.c\n+++ b/builtin-ls-files.c\n@@ -401,8 +401,8 @@ static void overlay_tree(const char *tree_name, const char *prefix)\n static const char ls_files_usage[] =\n \t\"git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* \"\n \t\"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] \"\n-\t\"[ --exclude-per-directory=<filename> ] [--full-name] [--abbrev] \"\n-\t\"[--] [<file>]*\";\n+\t\"[ --exclude-per-directory=<filename> ] [--exclude-standard] \"\n+\t\"[--full-name] [--abbrev] [--] [<file>]*\";\n \n int cmd_ls_files(int argc, const char **argv, const char *prefix)\n {\n@@ -510,6 +510,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\t\tdir.exclude_per_dir = arg + 24;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--exclude-standard\")) {\n+\t\t\texc_given = 1;\n+\t\t\tsetup_standard_excludes(&dir);\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--full-name\")) {\n \t\t\tprefix_offset = 0;\n \t\t\tcontinue;\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex ac598f8..0317ad9 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -37,10 +37,7 @@ sub list_untracked {\n \t\tchomp $_;\n \t\t$_;\n \t}\n-\trun_cmd_pipe(qw(git ls-files --others\n-\t\t\t--exclude-per-directory=.gitignore),\n-\t\t     \"--exclude-from=$GIT_DIR/info/exclude\",\n-\t\t     '--', @_);\n+\trun_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);\n }\n \n my $status_fmt = '%12s %12s %s';\n"},{"id":"59941","messageId":"7vk5ok6jn5.fsf@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"7v4pfo813i.fsf_-_@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Unify the use of standard set of exclude files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-15T07:41:02Z","receivedAt":"2007-11-15T07:41:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"By the way, I think the way in which excluded() is called inside\nls-files for --cached, --staged, --deleted and --modified is\ntotally bogus, and as a result, ls-files does not honor\nper-directory exclude files properly.\n\nThis is because dir.c:excluded() needs to be called after\nsetting up the exclude_list stack properly, just like how\ndir.c:read_directory() and unpack-trees.c:unpack_trees_rec()\ndo.  The directory traversal should look like this:\n\n - Call push_exclude_per_directory() upon entering a directory.\n   This reads the per directory exclude file (.gitignore) from\n   the directory, and push it into the existing stack.  This\n   way, the patterns from the file is set up to override the\n   existing patterns from the .gitignore files of higher level\n   directories.\n\n - Ask excluded() if your paths in that directory matches, and\n   do whatever you want to happen.\n\n - Call pop_exclude_per_directory() when leaving the directory,\n   to free the patterns read from the .gitignore file there.\n\nBecause the codepaths in question just iterate over the cache\nentries without telling the per-directory exclude file stack\nwhich set of .gitignore files should apply to the inquiry using\npush/pop mechanism, I _think_ excluded(dir, \"a/b\") calls in the\ncodepaths do not honor .gitignore nor a/.gitignore file when\nchecking if \"a/b\" is to be ignored.\n\nThe push/pop mechanism was designed to be used in read_directory()\nand it was a good match to the code structure to make recursive\ncalls to read_directory_recursive().  Because the paths are\nsorted in the pathname order, we can make appropriate calls to\npush/pop while iterating over the cache in these codepaths to\nfix this issue.\n\nAs a longer term fix, I think it makes more sense to make\nexcluded() automatically push/pop the per directory exclude file\nstack, just like the gitattributes mechanism maintains the\nattribute stack to match and cache the last checked path.\n"},{"id":"59959","messageId":"7vbq9v6fue.fsf@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"20071115070429.GD10185@sigill.intra.peff.net","subject":"Re: [PATCH] Unify the use of standard set of exclude files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-15T09:03:05Z","receivedAt":"2007-11-15T09:03:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> git-add--interactive:list_untracked needs something like this, but I\n> don't think your patch will work. We need something more like this (also\n> on maint because your standard exclude patch is):\n>\n> -- >8 --\n> git-ls-files: add --exclude-standard\n>\n> This provides a way for scripts to get at the new standard exclude\n> function.\n\nI like this, along with the patch to add--interactive.\n\nWill forge your signature ;-).\n"},{"id":"59960","messageId":"20071115091505.GA1853@sigill.intra.peff.net","threadId":"10855","inReplyTo":"7vbq9v6fue.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Unify the use of standard set of exclude files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-15T09:15:06Z","receivedAt":"2007-11-15T09:15:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 15, 2007 at 01:03:05AM -0800, Junio C Hamano wrote:\n\n> Will forge your signature ;-).\n\nOops, thank you. :)\n\n-Peff\n"},{"id":"59966","messageId":"vpqbq9vlt3k.fsf@bauges.imag.fr","threadId":"10855","inReplyTo":"7vsl39l0b7.fsf@gitster.siamese.dyndns.org","subject":"Re: git-clean won't read global ignore","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-11-15T10:07:43Z","receivedAt":"2007-11-15T10:07:43Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> We probably could change git-ls-files to use the standard set\n> when no excludes are specified from the command line, or\n> something like that, but this will be a change in semantics that\n> would affect the scripts in a subtle way.  I am somewhat\n> reluctant to make such a change.\n\n+1 for your introduction of setup_standard_excludes().\n\nAnd woh, I was writting a mail to say that adding a --exclude-standard\nwould be cool, but it has been implemented even before I said it would\nbe cool.\n\nNothing to add, except \"Thanks Junio, Thanks Jeff!\" :-).\n\nAt last, I'll be able to write\n\n$ git ls-files -o --exclude-standard >> .gitignore\n$ $EDITOR .gitignore\n\n-- \nMatthieu\n"},{"id":"60004","messageId":"7v7ikj5shd.fsf@gitster.siamese.dyndns.org","threadId":"10855","inReplyTo":"vpqbq9vlt3k.fsf@bauges.imag.fr","subject":"Re: git-clean won't read global ignore","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-15T17:27:42Z","receivedAt":"2007-11-15T17:27:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> At last, I'll be able to write\n>\n> $ git ls-files -o --exclude-standard >> .gitignore\n> $ $EDITOR .gitignore\n\nI think this is a good cookbook material to put somewhere in the\ndocs.\n"},{"id":"60008","messageId":"vpqfxz71jq9.fsf@bauges.imag.fr","threadId":"10855","inReplyTo":"7v7ikj5shd.fsf@gitster.siamese.dyndns.org","subject":"Re: git-clean won't read global ignore","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-11-15T17:50:22Z","receivedAt":"2007-11-15T17:50:22Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n>\n>> At last, I'll be able to write\n>>\n>> $ git ls-files -o --exclude-standard >> .gitignore\n>> $ $EDITOR .gitignore\n>\n> I think this is a good cookbook material to put somewhere in the\n> docs.\n\nHere it is:\n\nhttp://git.or.cz/gitwiki/GitTips?action=diff&rev2=217&rev1=216\n\n== How to ignore files which are \"Untracked\" now? ==\n\n{{{\n$ git ls-files -o --exclude-standard >> .gitignore\n$ $EDITOR .gitignore\n}}}\n\n(note : `--exclude-standard` is not yet in a released version of git\nas of november 2007, you'll have to use `--exclude-from=.gitignore\n--exclude-from=.git/info/exclude ...` if you don't have it).\n\n-- \nMatthieu\n"}]}