git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] add: Support specifying an excludes file with a configuration variable

From
James Bowes <jbowes@dangerouslyinc.com>
Date
Feb 28, 2007, 03:31 UTC
Message-ID
<3f80363f0702271931m266cdeeaob798e81c085456cd@mail.gmail.com>

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>
---

This is a solution to the 'User-wide ignore list' from the recent unresolved issues email. Thanks go to Junio for the implementation suggestion.

 builtin-add.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 87e16aa..9fcf514 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -12,6 +12,8 @@
 static const char builtin_add_usage[] =
 "git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>...";

+static const char *excludes_file;
+
 static void prune_directory(struct dir_struct *dir, const char
**pathspec, int prefix)
 {
 	char *seen;
@@ -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[] =
@@ -115,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);
-- 
1.4.4.2
Message 1 of 1 in “add: Support specifying an excludes file with a configuration variable”
  1. add: Support specifying an excludes file with a configuration variableJames Bowes, Feb 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.