Skip to content

Commit 7fb0eaa

Browse files
committed
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 <[email protected]>
1 parent dea4562 commit 7fb0eaa

File tree

9 files changed

+19
-14
lines changed

9 files changed

+19
-14
lines changed

archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ static void setup_archive_check(struct git_attr_check *check)
8787
static struct git_attr *attr_export_subst;
8888

8989
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");
9292
}
9393
check[0].attr = attr_export_ignore;
9494
check[1].attr = attr_export_subst;

attr.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int invalid_attr_name(const char *name, int namelen)
6565
return 0;
6666
}
6767

68-
struct git_attr *git_attr(const char *name, int len)
68+
static struct git_attr *git_attr_internal(const char *name, int len)
6969
{
7070
unsigned hval = hash_name(name, len);
7171
unsigned pos = hval % HASHSIZE;
@@ -95,6 +95,11 @@ struct git_attr *git_attr(const char *name, int len)
9595
return a;
9696
}
9797

98+
struct git_attr *git_attr(const char *name)
99+
{
100+
return git_attr_internal(name, strlen(name));
101+
}
102+
98103
/*
99104
* .gitattributes file is one line per record, each of which is
100105
*
@@ -162,7 +167,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
162167
else {
163168
e->setto = xmemdupz(equals + 1, ep - equals - 1);
164169
}
165-
e->attr = git_attr(cp, len);
170+
e->attr = git_attr_internal(cp, len);
166171
}
167172
(*num_attr)++;
168173
return ep + strspn(ep, blank);
@@ -221,7 +226,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
221226
sizeof(struct attr_state) * num_attr +
222227
(is_macro ? 0 : namelen + 1));
223228
if (is_macro)
224-
res->u.attr = git_attr(name, namelen);
229+
res->u.attr = git_attr_internal(name, namelen);
225230
else {
226231
res->u.pattern = (char *)&(res->state[num_attr]);
227232
memcpy(res->u.pattern, name, namelen);

attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct git_attr;
88
* Given a string, return the gitattribute object that
99
* corresponds to it.
1010
*/
11-
struct git_attr *git_attr(const char *, int);
11+
struct git_attr *git_attr(const char *);
1212

1313
/* Internal use */
1414
extern const char git_attr__true[];

builtin-check-attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
106106
const char *name;
107107
struct git_attr *a;
108108
name = argv[i];
109-
a = git_attr(name, strlen(name));
109+
a = git_attr(name);
110110
if (!a)
111111
return error("%s: not a valid attribute name", name);
112112
check[i].attr = a;

builtin-pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static void setup_delta_attr_check(struct git_attr_check *check)
673673
static struct git_attr *attr_delta;
674674

675675
if (!attr_delta)
676-
attr_delta = git_attr("delta", 5);
676+
attr_delta = git_attr("delta");
677677

678678
check[0].attr = attr_delta;
679679
}

convert.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ static void setup_convert_check(struct git_attr_check *check)
377377
static struct git_attr *attr_filter;
378378

379379
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");
383383
user_convert_tail = &user_convert;
384384
git_config(read_convert_config, NULL);
385385
}

ll-merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static const char *git_path_check_merge(const char *path)
344344
static struct git_attr_check attr_merge_check;
345345

346346
if (!attr_merge_check.attr)
347-
attr_merge_check.attr = git_attr("merge", 5);
347+
attr_merge_check.attr = git_attr("merge");
348348

349349
if (git_checkattr(path, 1, &attr_merge_check))
350350
return NULL;

userdiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path)
198198
struct git_attr_check check;
199199

200200
if (!attr)
201-
attr = git_attr("diff", 4);
201+
attr = git_attr("diff");
202202
check.attr = attr;
203203

204204
if (!path)

ws.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void setup_whitespace_attr_check(struct git_attr_check *check)
6464
static struct git_attr *attr_whitespace;
6565

6666
if (!attr_whitespace)
67-
attr_whitespace = git_attr("whitespace", 10);
67+
attr_whitespace = git_attr("whitespace");
6868
check[0].attr = attr_whitespace;
6969
}
7070

0 commit comments

Comments
 (0)