attr: convert git_check_attrs() callers to use the new API
The remaining callers are all simple "I have N attributes I am interested in. I'll ask about them with various paths one by one". After this step, no caller to git_check_attrs() remains. After removing it, we can extend "struct attr_check" struct with data that can be used in optimizing the query for the specific N attributes it contains. 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:
19
userdiff.c
19
userdiff.c
@ -262,25 +262,22 @@ struct userdiff_driver *userdiff_find_by_name(const char *name) {
|
||||
|
||||
struct userdiff_driver *userdiff_find_by_path(const char *path)
|
||||
{
|
||||
static struct git_attr *attr;
|
||||
struct attr_check_item check;
|
||||
|
||||
if (!attr)
|
||||
attr = git_attr("diff");
|
||||
check.attr = attr;
|
||||
static struct attr_check *check;
|
||||
|
||||
if (!check)
|
||||
check = attr_check_initl("diff", NULL);
|
||||
if (!path)
|
||||
return NULL;
|
||||
if (git_check_attrs(path, 1, &check))
|
||||
if (git_check_attr(path, check))
|
||||
return NULL;
|
||||
|
||||
if (ATTR_TRUE(check.value))
|
||||
if (ATTR_TRUE(check->items[0].value))
|
||||
return &driver_true;
|
||||
if (ATTR_FALSE(check.value))
|
||||
if (ATTR_FALSE(check->items[0].value))
|
||||
return &driver_false;
|
||||
if (ATTR_UNSET(check.value))
|
||||
if (ATTR_UNSET(check->items[0].value))
|
||||
return NULL;
|
||||
return userdiff_find_by_name(check.value);
|
||||
return userdiff_find_by_name(check->items[0].value);
|
||||
}
|
||||
|
||||
struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
|
||||
|
Reference in New Issue
Block a user