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

[PATCH 3/5] exclude: convert "check_index" into a flags field

From
Jeff King <peff@peff.net>
Date
Nov 2, 2016, 13:07 UTC
Message-ID
<20161102130709.5dm5hmrgknadf5zm@sigill.intra.peff.net>
In-Reply-To
<20161102130432.d3zprdul4sqgcfwu@sigill.intra.peff.net>

We pass the "check_index" flag through the variants of add_excludes(). Let's turn this into a full flags bit-field, so that we can add more flags to it without affecting the function signature.

Note that only one caller actually needs to use the new flag name, as the rest all were passing "0" already.

Signed-off-by: Jeff King <peff@peff.net>
---
 dir.c | 13 +++++++++----
 dir.h |  2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dir.c b/dir.c
index bfa8c8a9a..4fa1ca109 100644
--- a/dir.c
+++ b/dir.c
@@ -691,6 +691,9 @@ static void invalidate_directory(struct untracked_cache *uc,
 		dir->dirs[i]->recurse = 0;
 }
 
+/* Flags for add_excludes() */
+#define EXCLUDE_CHECK_INDEX (1<<0)
+
 /*
  * Given a file with name "fname", read it (either from disk, or from
  * the index if "check_index" is non-zero), parse it and store the
@@ -701,9 +704,10 @@ static void invalidate_directory(struct untracked_cache *uc,
  * ss_valid is non-zero, "ss" must contain good value as input.
  */
 static int add_excludes(const char *fname, const char *base, int baselen,
-			struct exclude_list *el, int check_index,
+			struct exclude_list *el, unsigned flags,
 			struct sha1_stat *sha1_stat)
 {
+	int check_index = !!(flags & EXCLUDE_CHECK_INDEX);
 	struct stat st;
 	int fd, i, lineno = 1;
 	size_t size = 0;
@@ -787,9 +791,9 @@ static int add_excludes(const char *fname, const char *base, int baselen,
 
 int add_excludes_from_file_to_list(const char *fname, const char *base,
 				   int baselen, struct exclude_list *el,
-				   int check_index)
+				   unsigned flags)
 {
-	return add_excludes(fname, base, baselen, el, check_index, NULL);
+	return add_excludes(fname, base, baselen, el, flags, NULL);
 }
 
 struct exclude_list *add_exclude_list(struct dir_struct *dir,
@@ -1125,7 +1129,8 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 			strbuf_addbuf(&sb, &dir->basebuf);
 			strbuf_addstr(&sb, dir->exclude_per_dir);
 			el->src = strbuf_detach(&sb, NULL);
-			add_excludes(el->src, el->src, stk->baselen, el, 1,
+			add_excludes(el->src, el->src, stk->baselen, el,
+				     EXCLUDE_CHECK_INDEX,
 				     untracked ? &sha1_stat : NULL);
 		}
 		/*
diff --git a/dir.h b/dir.h
index 97c83bb38..ba7eb924c 100644
--- a/dir.h
+++ b/dir.h
@@ -239,7 +239,7 @@ extern int is_excluded(struct dir_struct *dir, const char *name, int *dtype);
 extern struct exclude_list *add_exclude_list(struct dir_struct *dir,
 					     int group_type, const char *src);
 extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
-					  struct exclude_list *el, int check_index);
+					  struct exclude_list *el, unsigned flags);
 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
 extern void parse_exclude_pattern(const char **string, int *patternlen, unsigned *flags, int *nowildcardlen);
 extern void add_exclude(const char *string, const char *base,
-- 
2.11.0.rc0.258.gf434c15
Previous: Jeff KingNext: Jeff King
Message 4 of 22 in “disallow symlinks for .gitignore and .gitattributes”
  1. 0/5 disallow symlinks for .gitignore and .gitattributesJeff King, Nov 2, 2016
  2. 1/5 add open_nofollow() helperJeff King, Nov 2, 2016
  3. 2/5 attr: convert "macro_ok" into a flags fieldJeff King, Nov 2, 2016
  4. 3/5 exclude: convert "check_index" into a flags fieldJeff King, Nov 2, 2016
  5. 4/5 attr: do not respect symlinks for in-tree .gitattributesJeff King, Nov 2, 2016
  6. Duy NguyenNov 7, 2016
  7. Jeff KingNov 7, 2016
  8. Jeff KingNov 7, 2016
  9. Duy NguyenNov 8, 2016
  10. Jeff KingNov 8, 2016
  11. Duy NguyenNov 9, 2016
  12. Jeff KingNov 9, 2016
  13. Junio C HamanoNov 9, 2016
  14. Jeff KingNov 9, 2016
  15. Junio C HamanoNov 9, 2016
  16. Jeff KingNov 9, 2016
  17. Junio C HamanoNov 10, 2016
  18. Jeff KingNov 10, 2016
  19. Duy NguyenNov 10, 2016
  20. 5/5 exclude: do not respect symlinks for in-tree .gitignoreJeff King, Nov 2, 2016
  21. Stefan BellerNov 2, 2016
  22. Jeff KingNov 2, 2016

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.