aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-add.c22
-rw-r--r--cache.h1
-rw-r--r--config.c7
-rw-r--r--dir.c12
-rw-r--r--dir.h1
-rw-r--r--environment.c1
-rw-r--r--wt-status.c15
7 files changed, 25 insertions, 34 deletions
diff --git a/builtin-add.c b/builtin-add.c
index 77dcde693..cf815a0b8 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -21,7 +21,6 @@ static const char * const builtin_add_usage[] = {
};
static int take_worktree_changes;
-static const char *excludes_file;
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
{
@@ -61,12 +60,7 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec,
memset(dir, 0, sizeof(*dir));
if (!ignored_too) {
dir->collect_ignored = 1;
- dir->exclude_per_dir = ".gitignore";
- path = git_path("info/exclude");
- if (!access(path, R_OK))
- add_excludes_from_file(dir, path);
- if (excludes_file != NULL && !access(excludes_file, R_OK))
- add_excludes_from_file(dir, excludes_file);
+ setup_standard_excludes(dir);
}
/*
@@ -141,18 +135,6 @@ static void refresh(int verbose, const char **pathspec)
free(seen);
}
-static int git_add_config(const char *var, const char *value)
-{
- if (!strcmp(var, "core.excludesfile")) {
- if (!value)
- die("core.excludesfile without value");
- excludes_file = xstrdup(value);
- return 0;
- }
-
- return git_default_config(var, value);
-}
-
int interactive_add(void)
{
const char *argv[2] = { "add--interactive", NULL };
@@ -193,7 +175,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
exit(interactive_add());
}
- git_config(git_add_config);
+ git_config(git_default_config);
newfd = hold_locked_index(&lock_file, 1);
diff --git a/cache.h b/cache.h
index f4f27cd70..33ebccf48 100644
--- a/cache.h
+++ b/cache.h
@@ -581,6 +581,7 @@ extern int pager_in_use;
extern int pager_use_color;
extern char *editor_program;
+extern char *excludes_file;
/* base85 */
int decode_85(char *dst, const char *line, int linelen);
diff --git a/config.c b/config.c
index dc3148d45..56e99fc0f 100644
--- a/config.c
+++ b/config.c
@@ -431,6 +431,13 @@ int git_default_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.excludesfile")) {
+ if (!value)
+ die("core.excludesfile without value");
+ excludes_file = xstrdup(value);
+ return 0;
+ }
+
/* Add other config variables here and to Documentation/config.txt. */
return 0;
}
diff --git a/dir.c b/dir.c
index 01790ab27..fa9f9021e 100644
--- a/dir.c
+++ b/dir.c
@@ -778,3 +778,15 @@ int remove_dir_recursively(struct strbuf *path, int only_empty)
ret = rmdir(path->buf);
return ret;
}
+
+void setup_standard_excludes(struct dir_struct *dir)
+{
+ const char *path;
+
+ dir->exclude_per_dir = ".gitignore";
+ path = git_path("info/exclude");
+ if (!access(path, R_OK))
+ add_excludes_from_file(dir, path);
+ if (excludes_file && !access(excludes_file, R_OK))
+ add_excludes_from_file(dir, excludes_file);
+}
diff --git a/dir.h b/dir.h
index aaa247b25..82009dc13 100644
--- a/dir.h
+++ b/dir.h
@@ -71,6 +71,7 @@ extern struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna
extern char *get_relative_cwd(char *buffer, int size, const char *dir);
extern int is_inside_dir(const char *dir);
+extern void setup_standard_excludes(struct dir_struct *dir);
extern int remove_dir_recursively(struct strbuf *path, int only_empty);
#endif
diff --git a/environment.c b/environment.c
index b5a6c69f7..1dab72ec1 100644
--- a/environment.c
+++ b/environment.c
@@ -34,6 +34,7 @@ char *pager_program;
int pager_in_use;
int pager_use_color = 1;
char *editor_program;
+char *excludes_file;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
/* This is set by setup_git_dir_gently() and/or git_default_config() */
diff --git a/wt-status.c b/wt-status.c
index 03b5ec448..9a6ef4a89 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -22,7 +22,6 @@ static const char use_add_rm_msg[] =
"use \"git add/rm <file>...\" to update what will be committed";
static const char use_add_to_include_msg[] =
"use \"git add <file>...\" to include in what will be committed";
-static const char *excludes_file;
static int parse_status_slot(const char *var, int offset)
{
@@ -251,22 +250,16 @@ static void wt_status_print_changed(struct wt_status *s)
static void wt_status_print_untracked(struct wt_status *s)
{
struct dir_struct dir;
- const char *x;
int i;
int shown_header = 0;
memset(&dir, 0, sizeof(dir));
- dir.exclude_per_dir = ".gitignore";
if (!s->untracked) {
dir.show_other_directories = 1;
dir.hide_empty_directories = 1;
}
- x = git_path("info/exclude");
- if (file_exists(x))
- add_excludes_from_file(&dir, x);
- if (excludes_file && file_exists(excludes_file))
- add_excludes_from_file(&dir, excludes_file);
+ setup_standard_excludes(&dir);
read_directory(&dir, ".", "", 0, NULL);
for(i = 0; i < dir.nr; i++) {
@@ -364,11 +357,5 @@ int git_status_config(const char *k, const char *v)
int slot = parse_status_slot(k, 13);
color_parse(v, k, wt_status_colors[slot]);
}
- if (!strcmp(k, "core.excludesfile")) {
- if (!v)
- die("core.excludesfile without value");
- excludes_file = xstrdup(v);
- return 0;
- }
return git_default_config(k, v);
}