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

[PATCH 4/6] builtin/add.c: use path_excluded()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 6, 2012, 05:45 UTC
Message-ID
<1338961519-30970-5-git-send-email-gitster@pobox.com>
In-Reply-To
<1338961519-30970-1-git-send-email-gitster@pobox.com>

This only happens in --ignore-missing --dry-run codepath which presumably nobody should care, but is for completeness.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/add.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/add.c b/builtin/add.c
index c59b0c9..e5b40d9 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -441,6 +441,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
 	if (pathspec) {
 		int i;
+		struct path_exclude_check check;
+
+		path_exclude_check_init(&check, &dir);
 		if (!seen)
 			seen = find_used_pathspec(pathspec);
 		for (i = 0; pathspec[i]; i++) {
@@ -448,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 			    && !file_exists(pathspec[i])) {
 				if (ignore_missing) {
 					int dtype = DT_UNKNOWN;
-					if (excluded(&dir, pathspec[i], &dtype))
+					if (path_excluded(&check, pathspec[i], -1, &dtype))
 						dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
 				} else
 					die(_("pathspec '%s' did not match any files"),
@@ -456,6 +459,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 			}
 		}
 		free(seen);
+		path_exclude_check_clear(&check);
 	}
 
 	exit_status |= add_files_to_cache(prefix, pathspec, flags);
-- 
1.7.11.rc1.37.g09843ac
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “"ls-files -i" not honoring directory wide ignore”
  1. 0/6 "ls-files -i" not honoring directory wide ignoreJunio C Hamano, Jun 6, 2012
  2. 1/6 ls-files -i: pay attention to exclusion of leading pathsJunio C Hamano, Jun 6, 2012
  3. 2/6 ls-files -i: micro-optimize path_excluded()Junio C Hamano, Jun 6, 2012
  4. 3/6 path_excluded(): update API to less cache-entry centricJunio C Hamano, Jun 6, 2012
  5. 4/6 builtin/add.c: use path_excluded()Junio C Hamano, Jun 6, 2012
  6. 5/6 unpack-trees.c: use path_excluded() in check_ok_to_remove()Junio C Hamano, Jun 6, 2012
  7. 6/6 dir.c: make excluded() file scope staticJunio C Hamano, Jun 6, 2012

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.