From: Junio C Hamano Date: Sun, 17 Jan 2010 04:39:59 +0000 (-0800) Subject: git_attr(): fix function signature X-Git-Tag: v1.7.0-rc0~53^2~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7fb0eaa2;p=git.git git_attr(): fix function signature The function took (name, namelen) as its arguments, but all the public callers wanted to pass a full string. Demote the counted-string interface to an internal API status, and allow public callers to just pass the string to the function. Signed-off-by: Junio C Hamano --- diff --git a/archive.c b/archive.c index 55b273246..a9ebdc5d5 100644 --- a/archive.c +++ b/archive.c @@ -87,8 +87,8 @@ static void setup_archive_check(struct git_attr_check *check) static struct git_attr *attr_export_subst; if (!attr_export_ignore) { - attr_export_ignore = git_attr("export-ignore", 13); - attr_export_subst = git_attr("export-subst", 12); + attr_export_ignore = git_attr("export-ignore"); + attr_export_subst = git_attr("export-subst"); } check[0].attr = attr_export_ignore; check[1].attr = attr_export_subst; diff --git a/attr.c b/attr.c index 55bdb7cde..f5346ed32 100644 --- a/attr.c +++ b/attr.c @@ -65,7 +65,7 @@ static int invalid_attr_name(const char *name, int namelen) return 0; } -struct git_attr *git_attr(const char *name, int len) +static struct git_attr *git_attr_internal(const char *name, int len) { unsigned hval = hash_name(name, len); unsigned pos = hval % HASHSIZE; @@ -95,6 +95,11 @@ struct git_attr *git_attr(const char *name, int len) return a; } +struct git_attr *git_attr(const char *name) +{ + return git_attr_internal(name, strlen(name)); +} + /* * .gitattributes file is one line per record, each of which is * @@ -162,7 +167,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp, else { e->setto = xmemdupz(equals + 1, ep - equals - 1); } - e->attr = git_attr(cp, len); + e->attr = git_attr_internal(cp, len); } (*num_attr)++; return ep + strspn(ep, blank); @@ -221,7 +226,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src, sizeof(struct attr_state) * num_attr + (is_macro ? 0 : namelen + 1)); if (is_macro) - res->u.attr = git_attr(name, namelen); + res->u.attr = git_attr_internal(name, namelen); else { res->u.pattern = (char *)&(res->state[num_attr]); memcpy(res->u.pattern, name, namelen); diff --git a/attr.h b/attr.h index 69b5767eb..450f49d64 100644 --- a/attr.h +++ b/attr.h @@ -8,7 +8,7 @@ struct git_attr; * Given a string, return the gitattribute object that * corresponds to it. */ -struct git_attr *git_attr(const char *, int); +struct git_attr *git_attr(const char *); /* Internal use */ extern const char git_attr__true[]; diff --git a/builtin-check-attr.c b/builtin-check-attr.c index 8bd043009..3016d29ca 100644 --- a/builtin-check-attr.c +++ b/builtin-check-attr.c @@ -106,7 +106,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix) const char *name; struct git_attr *a; name = argv[i]; - a = git_attr(name, strlen(name)); + a = git_attr(name); if (!a) return error("%s: not a valid attribute name", name); check[i].attr = a; diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 4429d53a1..9beff352d 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -673,7 +673,7 @@ static void setup_delta_attr_check(struct git_attr_check *check) static struct git_attr *attr_delta; if (!attr_delta) - attr_delta = git_attr("delta", 5); + attr_delta = git_attr("delta"); check[0].attr = attr_delta; } diff --git a/convert.c b/convert.c index 491e7141b..852fd6488 100644 --- a/convert.c +++ b/convert.c @@ -377,9 +377,9 @@ static void setup_convert_check(struct git_attr_check *check) static struct git_attr *attr_filter; if (!attr_crlf) { - attr_crlf = git_attr("crlf", 4); - attr_ident = git_attr("ident", 5); - attr_filter = git_attr("filter", 6); + attr_crlf = git_attr("crlf"); + attr_ident = git_attr("ident"); + attr_filter = git_attr("filter"); user_convert_tail = &user_convert; git_config(read_convert_config, NULL); } diff --git a/ll-merge.c b/ll-merge.c index 2d6b6d6cb..f4b0a0737 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -344,7 +344,7 @@ static const char *git_path_check_merge(const char *path) static struct git_attr_check attr_merge_check; if (!attr_merge_check.attr) - attr_merge_check.attr = git_attr("merge", 5); + attr_merge_check.attr = git_attr("merge"); if (git_checkattr(path, 1, &attr_merge_check)) return NULL; diff --git a/userdiff.c b/userdiff.c index 57529ae63..df992490d 100644 --- a/userdiff.c +++ b/userdiff.c @@ -198,7 +198,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path) struct git_attr_check check; if (!attr) - attr = git_attr("diff", 4); + attr = git_attr("diff"); check.attr = attr; if (!path) diff --git a/ws.c b/ws.c index 760b5743f..c0893386e 100644 --- a/ws.c +++ b/ws.c @@ -64,7 +64,7 @@ static void setup_whitespace_attr_check(struct git_attr_check *check) static struct git_attr *attr_whitespace; if (!attr_whitespace) - attr_whitespace = git_attr("whitespace", 10); + attr_whitespace = git_attr("whitespace"); check[0].attr = attr_whitespace; }