dir: separate public from internal portion of dir_struct

In order to make it clearer to callers what portions of dir_struct are
public API, and avoid errors from them setting fields that are meant as
internal API, split the fields used for internal implementation reasons
into a separate embedded struct.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren
2023-02-27 15:28:10 +00:00
committed by Junio C Hamano
parent b413a82712
commit 5fdf285e62
2 changed files with 102 additions and 94 deletions

82
dir.h
View File

@@ -215,14 +215,9 @@ struct dir_struct {
/* The number of members in `entries[]` array. */
int nr;
/* Internal use; keeps track of allocation of `entries[]` array.*/
int alloc;
/* The number of members in `ignored[]` array. */
int ignored_nr;
int ignored_alloc;
/* bit-field of options */
enum {
@@ -296,51 +291,62 @@ struct dir_struct {
*/
struct dir_entry **ignored;
/* Enable/update untracked file cache if set */
struct untracked_cache *untracked;
/**
* The name of the file to be read in each directory for excluded files
* (typically `.gitignore`).
*/
const char *exclude_per_dir;
/*
* We maintain three groups of exclude pattern lists:
*
* EXC_CMDL lists patterns explicitly given on the command line.
* EXC_DIRS lists patterns obtained from per-directory ignore files.
* EXC_FILE lists patterns from fallback ignore files, e.g.
* - .git/info/exclude
* - core.excludesfile
*
* Each group contains multiple exclude lists, a single list
* per source.
*/
struct dir_struct_internal {
/* Keeps track of allocation of `entries[]` array.*/
int alloc;
/* Keeps track of allocation of `ignored[]` array. */
int ignored_alloc;
/*
* We maintain three groups of exclude pattern lists:
*
* EXC_CMDL lists patterns explicitly given on the command line.
* EXC_DIRS lists patterns obtained from per-directory ignore
* files.
* EXC_FILE lists patterns from fallback ignore files, e.g.
* - .git/info/exclude
* - core.excludesfile
*
* Each group contains multiple exclude lists, a single list
* per source.
*/
#define EXC_CMDL 0
#define EXC_DIRS 1
#define EXC_FILE 2
struct exclude_list_group exclude_list_group[3];
struct exclude_list_group exclude_list_group[3];
/*
* Temporary variables which are used during loading of the
* per-directory exclude lists.
*
* exclude_stack points to the top of the exclude_stack, and
* basebuf contains the full path to the current
* (sub)directory in the traversal. Exclude points to the
* matching exclude struct if the directory is excluded.
*/
struct exclude_stack *exclude_stack;
struct path_pattern *pattern;
struct strbuf basebuf;
/*
* Temporary variables which are used during loading of the
* per-directory exclude lists.
*
* exclude_stack points to the top of the exclude_stack, and
* basebuf contains the full path to the current
* (sub)directory in the traversal. Exclude points to the
* matching exclude struct if the directory is excluded.
*/
struct exclude_stack *exclude_stack;
struct path_pattern *pattern;
struct strbuf basebuf;
/* Enable untracked file cache if set */
struct untracked_cache *untracked;
struct oid_stat ss_info_exclude;
struct oid_stat ss_excludes_file;
unsigned unmanaged_exclude_files;
/* Additional metadata related to 'untracked' */
struct oid_stat ss_info_exclude;
struct oid_stat ss_excludes_file;
unsigned unmanaged_exclude_files;
/* Stats about the traversal */
unsigned visited_paths;
unsigned visited_directories;
/* Stats about the traversal */
unsigned visited_paths;
unsigned visited_directories;
} internal;
};
#define DIR_INIT { 0 }