X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-add.c;h=9fcf514dbc4cb76e15b47142e77c4019997ecd5d;hb=b08bbae7e1676e5a47fa9054e268ff14ee819a3a;hp=e7a1b4d9ab43cbb7de48b099c3afb721903f516b;hpb=1fcdd62adf81a172f45c7c6a58177212d500b9d9;p=git.git diff --git a/builtin-add.c b/builtin-add.c index e7a1b4d9a..9fcf514db 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -10,7 +10,9 @@ #include "cache-tree.h" static const char builtin_add_usage[] = -"git-add [-n] [-v] [-f] [--interactive] [--] ..."; +"git-add [-n] [-v] [-f] [--interactive | -i] [--] ..."; + +static const char *excludes_file; static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { @@ -67,6 +69,8 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) path = git_path("info/exclude"); if (!access(path, R_OK)) add_excludes_from_file(dir, path); + if (!access(excludes_file, R_OK)) + add_excludes_from_file(dir, excludes_file); /* * Calculate common prefix for the pathspec, and @@ -88,6 +92,18 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) prune_directory(dir, pathspec, baselen); } +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); +} + static struct lock_file lock_file; static const char ignore_warning[] = @@ -102,7 +118,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) int add_interactive = 0; for (i = 1; i < argc; i++) { - if (!strcmp("--interactive", argv[i])) + if (!strcmp("--interactive", argv[i]) || + !strcmp("-i", argv[i])) add_interactive++; } if (add_interactive) { @@ -114,7 +131,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) exit(1); } - git_config(git_default_config); + git_config(git_add_config); newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);