git-status: respect core.excludesFile
git-add reads this variable, and honours the contents of that file if that exists. Match this behaviour in git-status, too. Noticed by Evan Carroll on IRC. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
May 22, 2007 at 01:12 UTC
0ba956d331e4c14fb1600a62044492c6c27af71a
4 files changed
+39
Documentation/config.txt
+5
@@ -263,6 +263,11 @@ You probably do not need to adjust this value.
263
+
264
Common unit suffixes of 'k', 'm', or 'g' are supported.
265
266
+core.excludeFile::
267
+ In addition to '.gitignore' (per-directory) and
268
+ '.git/info/exclude', git looks into this file for patterns
269
+ of files which are not meant to be tracked.
270
+
271
alias.*::
272
Command aliases for the gitlink:git[1] command wrapper - e.g.
273
after defining "alias.last = cat-file commit HEAD", the invocation
Documentation/git-status.txt
+5
@@ -42,6 +42,11 @@ mean the same thing and the latter is kept for backward
42
compatibility) and `color.status.<slot>` configuration variables
43
to colorize its output.
44
45
+As for gitlink:git-add[1], the configuration variable
46
+'core.excludesfile' can indicate a path to a file containing patterns
47
+of file names to exclude, in addition to patterns given in
48
+'info/exclude' and '.gitignore'.
49
+
50
51
Author
52
------
t/t3001-ls-files-others-exclude.sh
+20
@@ -79,4 +79,24 @@ test_expect_success \
79
>output &&
80
git diff expect output'
81
82
+cat > excludes-file << EOF
83
+*.[1-8]
84
+e*
85
+EOF
86
+
87
+git-config core.excludesFile excludes-file
88
+
89
+git-runstatus | grep "^# " > output
90
+
91
+cat > expect << EOF
92
+# .gitignore
93
+# a.6
94
+# one/
95
+# output
96
+# three/
97
+EOF
98
+
99
+test_expect_success 'git-status honours core.excludesfile' \
100
+ 'diff -u expect output'
101
+
102
test_done
wt-status.c
+9
@@ -22,6 +22,7 @@ static const char use_add_rm_msg[] =
22
"use \"git add/rm <file>...\" to update what will be committed";
23
static const char use_add_to_include_msg[] =
24
"use \"git add <file>...\" to include in what will be committed";
25
+static const char *excludes_file;
26
27
static int parse_status_slot(const char *var, int offset)
28
{
@@ -259,6 +260,8 @@ static void wt_status_print_untracked(struct wt_status *s)
260
x = git_path("info/exclude");
261
if (file_exists(x))
262
add_excludes_from_file(&dir, x);
263
+ if (excludes_file && file_exists(excludes_file))
264
+ add_excludes_from_file(&dir, excludes_file);
265
266
read_directory(&dir, ".", "", 0);
267
for(i = 0; i < dir.nr; i++) {
@@ -356,5 +359,11 @@ int git_status_config(const char *k, const char *v)
359
int slot = parse_status_slot(k, 13);
360
color_parse(v, k, wt_status_colors[slot]);
361
}
362
+ if (!strcmp(k, "core.excludesfile")) {
363
+ if (!v)
364
+ die("core.excludesfile without value");
365
+ excludes_file = xstrdup(v);
366
+ return 0;
367
+ }
368
return git_default_config(k, v);
369
}