summaryrefslogtreecommitdiff
path: root/dir.h
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2013-01-06 16:58:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-06 22:26:37 (GMT)
commitc04318e46aae79b8b8df059e2118519d83dfee12 (patch)
tree714436b653a34517e552024b0d1d2c9f94644997 /dir.h
parentc082df24539329c2e75395cf378f0a3fe187c028 (diff)
downloadgit-c04318e46aae79b8b8df059e2118519d83dfee12.zip
git-c04318e46aae79b8b8df059e2118519d83dfee12.tar.gz
git-c04318e46aae79b8b8df059e2118519d83dfee12.tar.bz2
dir.c: keep track of where patterns came from
For exclude patterns read in from files, the filename is stored in the exclude list, and the originating line number is stored in the individual exclude (counting starting at 1). For exclude patterns provided on the command line, a string describing the source of the patterns is stored in the exclude list, and the sequence number assigned to each exclude pattern is negative, with counting starting at -1. So for example the 2nd pattern provided via --exclude would be numbered -2. This allows any future consumers of that data to easily distinguish between exclude patterns from files vs. from the CLI. Signed-off-by: Adam Spiers <git@adamspiers.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.h')
-rw-r--r--dir.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/dir.h b/dir.h
index c4d88db..64c410e 100644
--- a/dir.h
+++ b/dir.h
@@ -25,16 +25,32 @@ struct dir_entry {
struct exclude_list {
int nr;
int alloc;
+
/* remember pointer to exclude file contents so we can free() */
char *filebuf;
+ /* origin of list, e.g. path to filename, or descriptive string */
+ const char *src;
+
struct exclude {
+ /*
+ * This allows callers of last_exclude_matching() etc.
+ * to determine the origin of the matching pattern.
+ */
+ struct exclude_list *el;
+
const char *pattern;
int patternlen;
int nowildcardlen;
const char *base;
int baselen;
int flags;
+
+ /*
+ * Counting starts from 1 for line numbers in ignore files,
+ * and from -1 decrementing for patterns from CLI args.
+ */
+ int srcpos;
} **excludes;
};
@@ -144,13 +160,14 @@ extern struct exclude *last_exclude_matching_path(struct path_exclude_check *, c
extern int is_path_excluded(struct path_exclude_check *, const char *, int namelen, int *dtype);
-extern struct exclude_list *add_exclude_list(struct dir_struct *dir, int group_type);
+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);
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void parse_exclude_pattern(const char **string, int *patternlen, int *flags, int *nowildcardlen);
extern void add_exclude(const char *string, const char *base,
- int baselen, struct exclude_list *el);
+ int baselen, struct exclude_list *el, int srcpos);
extern void clear_exclude_list(struct exclude_list *el);
extern int file_exists(const char *);