diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-16 20:39:59 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-16 20:39:59 -0800 |
commit | 7fb0eaa289576a1dcd7751015ba791f1bce778a9 (patch) | |
tree | 76431538981b60bd62b95c810f3a18fe77f39355 | |
parent | dea4562bf5d1c27cd6c01b9cb65c3a8b8ee99a69 (diff) | |
download | git-7fb0eaa289576a1dcd7751015ba791f1bce778a9.tar.gz git-7fb0eaa289576a1dcd7751015ba791f1bce778a9.tar.xz |
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 <gitster@pobox.com>
-rw-r--r-- | archive.c | 4 | ||||
-rw-r--r-- | attr.c | 11 | ||||
-rw-r--r-- | attr.h | 2 | ||||
-rw-r--r-- | builtin-check-attr.c | 2 | ||||
-rw-r--r-- | builtin-pack-objects.c | 2 | ||||
-rw-r--r-- | convert.c | 6 | ||||
-rw-r--r-- | ll-merge.c | 2 | ||||
-rw-r--r-- | userdiff.c | 2 | ||||
-rw-r--r-- | ws.c | 2 |
9 files changed, 19 insertions, 14 deletions
@@ -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; @@ -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); @@ -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; } @@ -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) @@ -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; } |