Skip to content

Commit

Permalink
git_attr(): fix function signature
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gitster committed Jan 17, 2010
1 parent dea4562 commit 7fb0eaa
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion builtin-check-attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion ll-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion userdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7fb0eaa

Please sign in to comment.