зеркало из https://github.com/microsoft/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 <gitster@pobox.com>
This commit is contained in:
Родитель
dea4562bf5
Коммит
7fb0eaa289
|
@ -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;
|
||||
|
|
11
attr.c
11
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);
|
||||
|
|
2
attr.h
2
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[];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
2
ws.c
2
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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче