add: Support specifying an excludes file with a configuration variable
This adds the 'core.excludesfile' configuration variable. This variable can hold a path to a file containing patterns of file names to exclude from git-add, like $GIT_DIR/info/exclude. Patterns in the excludes file are used in addition to those in info/exclude. Signed-off-by: James Bowes <jbowes@dangerouslyinc.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
James Bowes committed
Feb 27, 2007 at 22:31 UTC
896bdfa2581f96d3df9a312510c39ce7d80790cd
1 file changed
+17
-1
builtin-add.c
+17
-1
@@ -12,6 +12,8 @@
12
static const char builtin_add_usage[] =
13
"git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>...";
14
15
+static const char *excludes_file;
16
+
17
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
18
{
19
char *seen;
@@ -67,6 +69,8 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec)
69
path = git_path("info/exclude");
70
if (!access(path, R_OK))
71
add_excludes_from_file(dir, path);
72
+ if (!access(excludes_file, R_OK))
73
+ add_excludes_from_file(dir, excludes_file);
74
75
/*
76
* Calculate common prefix for the pathspec, and
@@ -88,6 +92,18 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec)
92
prune_directory(dir, pathspec, baselen);
93
}
94
95
+static int git_add_config(const char *var, const char *value)
96
+{
97
+ if (!strcmp(var, "core.excludesfile")) {
98
+ if (!value)
99
+ die("core.excludesfile without value");
100
+ excludes_file = xstrdup(value);
101
+ return 0;
102
+ }
103
+
104
+ return git_default_config(var, value);
105
+}
106
+
107
static struct lock_file lock_file;
108
109
static const char ignore_warning[] =
@@ -115,7 +131,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
131
exit(1);
132
}
133
118
- git_config(git_default_config);
134
+ git_config(git_add_config);
135
136
newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
137