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

[PATCH 14/23] dir.c: export excluded_1() and add_excludes_from_file_1()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 14, 2009, 10:30 UTC
Message-ID
<1260786666-8405-15-git-send-email-pclouds@gmail.com>
In-Reply-To
<1260786666-8405-1-git-send-email-pclouds@gmail.com>

These functions are used to handle .gitignore. They are now exported so that sparse checkout can reuse.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 dir.c |   32 ++++++++++++++++----------------
 dir.h |    4 ++++
 2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/dir.c b/dir.c
index 7735cea..6b1c478 100644
--- a/dir.c
+++ b/dir.c
@@ -223,12 +223,12 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
 	return data;
 }
 
-static int add_excludes_from_file_1(const char *fname,
-				    const char *base,
-				    int baselen,
-				    char **buf_p,
-				    struct exclude_list *which,
-				    int check_index)
+int add_excludes_from_file_to_list(const char *fname,
+				   const char *base,
+				   int baselen,
+				   char **buf_p,
+				   struct exclude_list *which,
+				   int check_index)
 {
 	struct stat st;
 	int fd, i;
@@ -274,8 +274,8 @@ static int add_excludes_from_file_1(const char *fname,
 
 void add_excludes_from_file(struct dir_struct *dir, const char *fname)
 {
-	if (add_excludes_from_file_1(fname, "", 0, NULL,
-				     &dir->exclude_list[EXC_FILE], 0) < 0)
+	if (add_excludes_from_file_to_list(fname, "", 0, NULL,
+					   &dir->exclude_list[EXC_FILE], 0) < 0)
 		die("cannot use %s as an exclude file", fname);
 }
 
@@ -324,9 +324,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 		memcpy(dir->basebuf + current, base + current,
 		       stk->baselen - current);
 		strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir);
-		add_excludes_from_file_1(dir->basebuf,
-					 dir->basebuf, stk->baselen,
-					 &stk->filebuf, el, 1);
+		add_excludes_from_file_to_list(dir->basebuf,
+					       dir->basebuf, stk->baselen,
+					       &stk->filebuf, el, 1);
 		dir->exclude_stack = stk;
 		current = stk->baselen;
 	}
@@ -336,9 +336,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 /* Scan the list and let the last match determine the fate.
  * Return 1 for exclude, 0 for include and -1 for undecided.
  */
-static int excluded_1(const char *pathname,
-		      int pathlen, const char *basename, int *dtype,
-		      struct exclude_list *el)
+int excluded_from_list(const char *pathname,
+		       int pathlen, const char *basename, int *dtype,
+		       struct exclude_list *el)
 {
 	int i;
 
@@ -412,8 +412,8 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
 
 	prep_exclude(dir, pathname, basename-pathname);
 	for (st = EXC_CMDL; st <= EXC_FILE; st++) {
-		switch (excluded_1(pathname, pathlen, basename,
-				   dtype_p, &dir->exclude_list[st])) {
+		switch (excluded_from_list(pathname, pathlen, basename,
+					   dtype_p, &dir->exclude_list[st])) {
 		case 0:
 			return 0;
 		case 1:
diff --git a/dir.h b/dir.h
index a631446..472e11e 100644
--- a/dir.h
+++ b/dir.h
@@ -69,7 +69,11 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
 extern int fill_directory(struct dir_struct *dir, const char **pathspec);
 extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
 
+extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
+			      int *dtype, struct exclude_list *el);
 extern int excluded(struct dir_struct *, const char *, int *);
+extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
+					  char **buf_p, struct exclude_list *which, int check_index);
 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
 extern void add_exclude(const char *string, const char *base,
 			int baselen, struct exclude_list *which);
-- 
1.6.5.2.216.g9c1ec
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 19 of 30 in “nd/sparse reroll”
  1. 00/23 nd/sparse rerollNguyễn Thái Ngọc Duy, Dec 14, 2009
  2. 01/23 update-index: refactor mark_valid() in preparation for new optionsNguyễn Thái Ngọc Duy, Dec 14, 2009
  3. 02/23 Add test-index-versionNguyễn Thái Ngọc Duy, Dec 14, 2009
  4. 03/23 Introduce "skip-worktree" bit in index, teach Git to get/set this bitNguyễn Thái Ngọc Duy, Dec 14, 2009
  5. Greg PriceDec 14, 2009
  6. Nguyen Thai Ngoc DuyDec 15, 2009
  7. Johannes SixtDec 15, 2009
  8. Nguyen Thai Ngoc DuyDec 15, 2009
  9. 04/23 update-index: ignore update request if it's skip-worktreeNguyễn Thái Ngọc Duy, Dec 14, 2009
  10. 05/23 Teach ls-files and update-index to respect skip-worktree bitNguyễn Thái Ngọc Duy, Dec 14, 2009
  11. 06/23 Teach diff machinery to respect skip-worktree bitNguyễn Thái Ngọc Duy, Dec 14, 2009
  12. 07/23 Teach grep to respect skip-worktree bitNguyễn Thái Ngọc Duy, Dec 14, 2009
  13. 08/23 Teach commit to respect skip-worktree bitNguyễn Thái Ngọc Duy, Dec 14, 2009
  14. 09/23 Teach Git to respect skip-worktree bit (writing part)Nguyễn Thái Ngọc Duy, Dec 14, 2009
  15. 10/23 Avoid writing to buffer in add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Dec 14, 2009
  16. 11/23 Read .gitignore from index if it is skip-worktreeNguyễn Thái Ngọc Duy, Dec 14, 2009
  17. 12/23 unpack-trees(): carry skip-worktree bit over in merged_entry()Nguyễn Thái Ngọc Duy, Dec 14, 2009
  18. 13/23 excluded_1(): support exclude files in indexNguyễn Thái Ngọc Duy, Dec 14, 2009
  19. 14/23 dir.c: export excluded_1() and add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Dec 14, 2009
  20. 15/23 Introduce "sparse checkout"Nguyễn Thái Ngọc Duy, Dec 14, 2009
  21. 16/23 unpack-trees(): add CE_WT_REMOVE to remove on worktree aloneNguyễn Thái Ngọc Duy, Dec 14, 2009
  22. 17/23 unpack-trees.c: generalize verify_* functionsNguyễn Thái Ngọc Duy, Dec 14, 2009
  23. 18/23 unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkoutNguyễn Thái Ngọc Duy, Dec 14, 2009
  24. 19/23 unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final indexNguyễn Thái Ngọc Duy, Dec 14, 2009
  25. 20/23 unpack-trees(): ignore worktree check outside checkout areaNguyễn Thái Ngọc Duy, Dec 14, 2009
  26. 21/23 read-tree: add --no-sparse-checkout to disable sparse checkout supportNguyễn Thái Ngọc Duy, Dec 14, 2009
  27. 22/23 Add tests for sparse checkoutNguyễn Thái Ngọc Duy, Dec 14, 2009
  28. 23/23 sparse checkout: inhibit empty worktreeNguyễn Thái Ngọc Duy, Dec 14, 2009
  29. Johannes SixtDec 14, 2009
  30. Nguyen Thai Ngoc DuyDec 14, 2009

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.