attr.c: outline the future plans by heavily commenting
Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
faa4e8ceb5
commit
7d42ec547c
40
attr.c
40
attr.c
@ -30,6 +30,11 @@ static const char git_attr__unknown[] = "(builtin)unknown";
|
||||
#define DEBUG_ATTR 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NEEDSWORK: the global dictionary of the interned attributes
|
||||
* must stay a singleton even after we become thread-ready.
|
||||
* Access to these must be surrounded with mutex when it happens.
|
||||
*/
|
||||
struct git_attr {
|
||||
struct git_attr *next;
|
||||
unsigned h;
|
||||
@ -39,10 +44,19 @@ struct git_attr {
|
||||
char name[FLEX_ARRAY];
|
||||
};
|
||||
static int attr_nr;
|
||||
static struct git_attr *(git_attr_hash[HASHSIZE]);
|
||||
|
||||
/*
|
||||
* NEEDSWORK: maybe-real, maybe-macro are not property of
|
||||
* an attribute, as it depends on what .gitattributes are
|
||||
* read. Once we introduce per git_attr_check attr_stack
|
||||
* and check_all_attr, the optimization based on them will
|
||||
* become unnecessary and can go away. So is this variable.
|
||||
*/
|
||||
static int cannot_trust_maybe_real;
|
||||
|
||||
/* NEEDSWORK: This will become per git_attr_check */
|
||||
static struct git_attr_check *check_all_attr;
|
||||
static struct git_attr *(git_attr_hash[HASHSIZE]);
|
||||
|
||||
const char *git_attr_name(const struct git_attr *attr)
|
||||
{
|
||||
@ -102,6 +116,11 @@ static struct git_attr *git_attr_internal(const char *name, int len)
|
||||
a->maybe_real = 0;
|
||||
git_attr_hash[pos] = a;
|
||||
|
||||
/*
|
||||
* NEEDSWORK: per git_attr_check check_all_attr
|
||||
* will be initialized a lot more lazily, not
|
||||
* like this, and not here.
|
||||
*/
|
||||
REALLOC_ARRAY(check_all_attr, attr_nr);
|
||||
check_all_attr[a->attr_nr].attr = a;
|
||||
check_all_attr[a->attr_nr].value = ATTR__UNKNOWN;
|
||||
@ -318,6 +337,7 @@ fail_return:
|
||||
* .gitignore file and info/excludes file as a fallback.
|
||||
*/
|
||||
|
||||
/* NEEDSWORK: This will become per git_attr_check */
|
||||
static struct attr_stack {
|
||||
struct attr_stack *prev;
|
||||
char *origin;
|
||||
@ -382,6 +402,24 @@ static struct attr_stack *read_attr_from_array(const char **list)
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* NEEDSWORK: these two are tricky. The callers assume there is a
|
||||
* single, system-wide global state "where we read attributes from?"
|
||||
* and when the state is flipped by calling git_attr_set_direction(),
|
||||
* attr_stack is discarded so that subsequent attr_check will lazily
|
||||
* read from the right place. And they do not know or care who called
|
||||
* by them uses the attribute subsystem, hence have no knowledge of
|
||||
* existing git_attr_check instances or future ones that will be
|
||||
* created).
|
||||
*
|
||||
* Probably we need a thread_local that holds these two variables,
|
||||
* and a list of git_attr_check instances (which need to be maintained
|
||||
* by hooking into git_attr_check_alloc(), git_attr_check_initl(), and
|
||||
* git_attr_check_clear(). Then git_attr_set_direction() updates the
|
||||
* fields in that thread_local for these two variables, iterate over
|
||||
* all the active git_attr_check instances and discard the attr_stack
|
||||
* they hold. Yuck, but it sounds doable.
|
||||
*/
|
||||
static enum git_attr_direction direction;
|
||||
static struct index_state *use_index;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user