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>
Junio C Hamano committed
Jan 16, 2010 at 20:39 UTC
7fb0eaa289576a1dcd7751015ba791f1bce778a9
9 files changed
+19
-14
archive.c
+2
-2
@@ -87,8 +87,8 @@ static void setup_archive_check(struct git_attr_check *check)
87
static struct git_attr *attr_export_subst;
88
89
if (!attr_export_ignore) {
90
- attr_export_ignore = git_attr("export-ignore", 13);
91
- attr_export_subst = git_attr("export-subst", 12);
90
+ attr_export_ignore = git_attr("export-ignore");
91
+ attr_export_subst = git_attr("export-subst");
92
}
93
check[0].attr = attr_export_ignore;
94
check[1].attr = attr_export_subst;
attr.c
+8
-3
@@ -65,7 +65,7 @@ static int invalid_attr_name(const char *name, int namelen)
65
return 0;
66
}
67
68
-struct git_attr *git_attr(const char *name, int len)
68
+static struct git_attr *git_attr_internal(const char *name, int len)
69
{
70
unsigned hval = hash_name(name, len);
71
unsigned pos = hval % HASHSIZE;
@@ -95,6 +95,11 @@ struct git_attr *git_attr(const char *name, int len)
95
return a;
96
}
97
98
+struct git_attr *git_attr(const char *name)
99
+{
100
+ return git_attr_internal(name, strlen(name));
101
+}
102
+
103
/*
104
* .gitattributes file is one line per record, each of which is
105
*
@@ -162,7 +167,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
167
else {
168
e->setto = xmemdupz(equals + 1, ep - equals - 1);
169
}
165
- e->attr = git_attr(cp, len);
170
+ e->attr = git_attr_internal(cp, len);
171
}
172
(*num_attr)++;
173
return ep + strspn(ep, blank);
@@ -221,7 +226,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
226
sizeof(struct attr_state) * num_attr +
227
(is_macro ? 0 : namelen + 1));
228
if (is_macro)
224
- res->u.attr = git_attr(name, namelen);
229
+ res->u.attr = git_attr_internal(name, namelen);
230
else {
231
res->u.pattern = (char *)&(res->state[num_attr]);
232
memcpy(res->u.pattern, name, namelen);
attr.h
+1
-1
@@ -8,7 +8,7 @@ struct git_attr;
8
* Given a string, return the gitattribute object that
9
* corresponds to it.
10
*/
11
-struct git_attr *git_attr(const char *, int);
11
+struct git_attr *git_attr(const char *);
12
13
/* Internal use */
14
extern const char git_attr__true[];
builtin-check-attr.c
+1
-1
@@ -106,7 +106,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
106
const char *name;
107
struct git_attr *a;
108
name = argv[i];
109
- a = git_attr(name, strlen(name));
109
+ a = git_attr(name);
110
if (!a)
111
return error("%s: not a valid attribute name", name);
112
check[i].attr = a;
builtin-pack-objects.c
+1
-1
@@ -673,7 +673,7 @@ static void setup_delta_attr_check(struct git_attr_check *check)
673
static struct git_attr *attr_delta;
674
675
if (!attr_delta)
676
- attr_delta = git_attr("delta", 5);
676
+ attr_delta = git_attr("delta");
677
678
check[0].attr = attr_delta;
679
}
convert.c
+3
-3
@@ -377,9 +377,9 @@ static void setup_convert_check(struct git_attr_check *check)
377
static struct git_attr *attr_filter;
378
379
if (!attr_crlf) {
380
- attr_crlf = git_attr("crlf", 4);
381
- attr_ident = git_attr("ident", 5);
382
- attr_filter = git_attr("filter", 6);
380
+ attr_crlf = git_attr("crlf");
381
+ attr_ident = git_attr("ident");
382
+ attr_filter = git_attr("filter");
383
user_convert_tail = &user_convert;
384
git_config(read_convert_config, NULL);
385
}
ll-merge.c
+1
-1
@@ -344,7 +344,7 @@ static const char *git_path_check_merge(const char *path)
344
static struct git_attr_check attr_merge_check;
345
346
if (!attr_merge_check.attr)
347
- attr_merge_check.attr = git_attr("merge", 5);
347
+ attr_merge_check.attr = git_attr("merge");
348
349
if (git_checkattr(path, 1, &attr_merge_check))
350
return NULL;
userdiff.c
+1
-1
@@ -198,7 +198,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path)
198
struct git_attr_check check;
199
200
if (!attr)
201
- attr = git_attr("diff", 4);
201
+ attr = git_attr("diff");
202
check.attr = attr;
203
204
if (!path)
ws.c
+1
-1
@@ -64,7 +64,7 @@ static void setup_whitespace_attr_check(struct git_attr_check *check)
64
static struct git_attr *attr_whitespace;
65
66
if (!attr_whitespace)
67
- attr_whitespace = git_attr("whitespace", 10);
67
+ attr_whitespace = git_attr("whitespace");
68
check[0].attr = attr_whitespace;
69
}
70