{"thread":{"id":"7005","subject":"[PATCH] add: Support specifying an excludes file with a configuration variable","startedAt":"2007-02-28T03:31:10Z","lastAt":"2007-02-28T03:31:10Z","messageCount":1,"participants":["James Bowes"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35762","messageId":"3f80363f0702271931m266cdeeaob798e81c085456cd@mail.gmail.com","threadId":"7005","inReplyTo":null,"subject":"[PATCH] add: Support specifying an excludes file with a configuration variable","fromName":"James Bowes","fromEmail":"jbowes@dangerouslyinc.com","sentAt":"2007-02-28T03:31:10Z","receivedAt":"2007-02-28T03:31:10Z","isPatch":true,"sender":{"key":"jbowes@dangerouslyinc.com","avatar":"https://gravatar.com/avatar/a2fe98c66b2b47a9fa9d2ba92ff949d54c3208b1f8acc2e745b4b84ae3c4483a?d=mp&s=160"},"body":"This adds the 'core.excludesfile' configuration variable. This variable can\nhold a path to a file containing patterns of file names to exclude from\ngit-add, like $GIT_DIR/info/exclude. Patterns in the excludes file are used\nin addition to those in info/exclude.\n\nSigned-off-by: James Bowes <jbowes@dangerouslyinc.com>\n---\n\nThis is a solution to the 'User-wide ignore list' from the recent unresolved\nissues email. Thanks go to Junio for the implementation suggestion.\n\n builtin-add.c |   18 +++++++++++++++++-\n 1 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 87e16aa..9fcf514 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -12,6 +12,8 @@\n static const char builtin_add_usage[] =\n \"git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>...\";\n\n+static const char *excludes_file;\n+\n static void prune_directory(struct dir_struct *dir, const char\n**pathspec, int prefix)\n {\n \tchar *seen;\n@@ -67,6 +69,8 @@ static void fill_directory(struct dir_struct *dir,\nconst char **pathspec)\n \tpath = git_path(\"info/exclude\");\n \tif (!access(path, R_OK))\n \t\tadd_excludes_from_file(dir, path);\n+\tif (!access(excludes_file, R_OK))\n+\t\tadd_excludes_from_file(dir, excludes_file);\n\n \t/*\n \t * Calculate common prefix for the pathspec, and\n@@ -88,6 +92,18 @@ static void fill_directory(struct dir_struct *dir,\nconst char **pathspec)\n \t\tprune_directory(dir, pathspec, baselen);\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_warning[] =\n@@ -115,7 +131,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\texit(1);\n \t}\n\n-\tgit_config(git_default_config);\n+\tgit_config(git_add_config);\n\n \tnewfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);\n\n-- \n1.4.4.2\n"}]}