void grep_source_load_driver(struct grep_source *gs) { if (gs->driver) return; grep_attr_lock(); if (gs->path) gs->driver = userdiff_find_by_path(gs->path); if (!gs->driver) gs->driver = userdiff_find_by_name("default"); grep_attr_unlock(); }
struct userdiff_driver *userdiff_find_by_path(struct index_state *istate, const char *path) { static struct attr_check *check; if (!check) check = attr_check_initl("diff", NULL); if (!path) return NULL; git_check_attr(istate, path, check); if (ATTR_TRUE(check->items[0].value)) return &driver_true; if (ATTR_FALSE(check->items[0].value)) return &driver_false; if (ATTR_UNSET(check->items[0].value)) return NULL; return userdiff_find_by_name(check->items[0].value); }
struct userdiff_driver *userdiff_find_by_path(const char *path) { static struct git_attr *attr; struct git_attr_check check; if (!attr) attr = git_attr("diff"); check.attr = attr; if (!path) return NULL; if (git_checkattr(path, 1, &check)) return NULL; if (ATTR_TRUE(check.value)) return &driver_true; if (ATTR_FALSE(check.value)) return &driver_false; if (ATTR_UNSET(check.value)) return NULL; return userdiff_find_by_name(check.value); }