From: Mirko Faina <mroik@delayed.space>
To: git@vger.kernel.org
Cc: Mirko Faina <mroik@delayed.space>, Jeff King <peff@peff.net>,
Junio C Hamano <gitster@pobox.com>,
Elijah Newren <newren@gmail.com>,
Derrick Stolee <stolee@gmail.com>
Subject: [RFC PATCH 2/6] dir.h: replace pattern macros with enum in attr.h
Date: Thu, 8 Oct 2026 14:06:58 +0200 [thread overview]
Message-ID: <adbfbf5aab70bdf8cdb2ac080ed79a3144edcb8d.1791460418.git.mroik@delayed.space> (raw)
In-Reply-To: <cover.1791460418.git.mroik@delayed.space>
dir.h defines some macros that are used in the dir.c machinery for
.gitignore files. These macros are only used for the pattern struct
defined in attr.h so it really should belong there.
Remove the macro definitions from dir.h and replace them with the
pattern_flags enum in attr.h.
Signed-off-by: Mirko Faina <mroik@delayed.space>
---
attr.h | 9 ++++++++-
builtin/check-ignore.c | 1 +
builtin/sparse-checkout.c | 1 +
dir.c | 5 +++--
dir.h | 8 ++------
5 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/attr.h b/attr.h
index a04a521092..c083d47df5 100644
--- a/attr.h
+++ b/attr.h
@@ -250,11 +250,18 @@ struct attr_state {
const char *setto;
};
+enum pattern_flags {
+ PATTERN_FLAG_NODIR = 1,
+ PATTERN_FLAG_ENDSWITH = 4,
+ PATTERN_FLAG_MUSTBEDIR = 8,
+ PATTERN_FLAG_NEGATIVE = 16,
+};
+
struct pattern {
const char *pattern;
int patternlen;
int nowildcardlen;
- unsigned flags; /* PATTERN_FLAG_* */
+ enum pattern_flags flags; /* PATTERN_FLAG_* */
};
/*
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 644c9a414f..fdf7610178 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -9,6 +9,7 @@
#include "parse-options.h"
#include "submodule.h"
#include "write-or-die.h"
+#include "attr.h"
static int quiet, verbose, stdin_paths, show_non_matching, no_index;
static const char * const check_ignore_usage[] = {
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index cb4a037b77..83981e2b1e 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -20,6 +20,7 @@
#include "setup.h"
#include "sparse-index.h"
#include "worktree.h"
+#include "attr.h"
static const char *empty_base = "";
diff --git a/dir.c b/dir.c
index d896e7be4b..c6342c882a 100644
--- a/dir.c
+++ b/dir.c
@@ -36,6 +36,7 @@
#include "trace2.h"
#include "tree.h"
#include "hex.h"
+#include "attr.h"
/*
* The maximum size of a pattern/exclude file. If the file exceeds this size
@@ -701,7 +702,7 @@ int no_wildcard(const char *string)
void parse_path_pattern(const char **pattern,
int *patternlen,
- unsigned *flags,
+ enum pattern_flags *flags,
int *nowildcardlen)
{
const char *p = *pattern;
@@ -979,7 +980,7 @@ void add_pattern(const char *string, const char *base,
{
struct path_pattern *pattern;
int patternlen;
- unsigned flags;
+ enum pattern_flags flags;
int nowildcardlen;
parse_path_pattern(&string, &patternlen, &flags, &nowildcardlen);
diff --git a/dir.h b/dir.h
index 83e0f648a8..210ee8a98d 100644
--- a/dir.h
+++ b/dir.h
@@ -6,6 +6,7 @@
#include "pathspec.h"
#include "statinfo.h"
#include "strbuf.h"
+#include "attr.h"
struct repository;
@@ -49,11 +50,6 @@ struct dir_entry {
char name[FLEX_ARRAY]; /* more */
};
-#define PATTERN_FLAG_NODIR 1
-#define PATTERN_FLAG_ENDSWITH 4
-#define PATTERN_FLAG_MUSTBEDIR 8
-#define PATTERN_FLAG_NEGATIVE 16
-
struct path_pattern {
/*
* This allows callers of last_matching_pattern() etc.
@@ -469,7 +465,7 @@ int add_patterns_from_blob_to_list(struct object_id *oid,
int add_patterns_from_buffer(char *buf, size_t size,
const char *base, int baselen,
struct pattern_list *pl);
-void parse_path_pattern(const char **string, int *patternlen, unsigned *flags, int *nowildcardlen);
+void parse_path_pattern(const char **string, int *patternlen, enum pattern_flags *flags, int *nowildcardlen);
void add_pattern(const char *string, const char *base,
int baselen, struct pattern_list *pl, int srcpos);
void clear_pattern_list(struct pattern_list *pl);
--
2.56.0
next prev parent reply other threads:[~2026-10-08 12:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 12:06 [RFC PATCH 0/6] Introduce precious files Mirko Faina
2026-10-08 12:06 ` [RFC PATCH 1/6] precious-files.txt: new document proposing new precious file type Mirko Faina
2026-10-08 12:06 ` Mirko Faina [this message]
2026-10-08 12:06 ` [RFC PATCH 3/6] dir.c: teach parse_path_pattern() precious files Mirko Faina
2026-10-08 12:07 ` [RFC PATCH 4/6] dir.c: teach add_pattern() reject precious pattern Mirko Faina
2026-10-08 12:07 ` [RFC PATCH 5/6] unpack-trees: teach check_ok_to_remove() precious Mirko Faina
2026-10-08 12:07 ` [RFC PATCH 6/6] builtin/ls-files.c: support for precious files Mirko Faina
2026-10-08 12:12 ` [RFC PATCH 0/6] Introduce " Mirko Faina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adbfbf5aab70bdf8cdb2ac080ed79a3144edcb8d.1791460418.git.mroik@delayed.space \
--to=mroik@delayed.space \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox