summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archive.c4
-rw-r--r--attr.c11
-rw-r--r--attr.h2
-rw-r--r--builtin-check-attr.c2
-rw-r--r--builtin-pack-objects.c2
-rw-r--r--convert.c6
-rw-r--r--ll-merge.c2
-rw-r--r--userdiff.c2
-rw-r--r--ws.c2
9 files changed, 19 insertions, 14 deletions
diff --git a/archive.c b/archive.c
index 55b273246e..a9ebdc5d54 100644
--- a/archive.c
+++ b/archive.c
@@ -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;
diff --git a/attr.c b/attr.c
index 55bdb7cdeb..f5346ed32a 100644
--- a/attr.c
+++ b/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);
diff --git a/attr.h b/attr.h
index 69b5767ebc..450f49d648 100644
--- a/attr.h
+++ b/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[];
diff --git a/builtin-check-attr.c b/builtin-check-attr.c
index 8bd0430098..3016d29caa 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 4429d53a1e..9beff352d5 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;
}
diff --git a/convert.c b/convert.c
index 491e7141b4..852fd6488a 100644
--- a/convert.c
+++ b/convert.c
@@ -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 2d6b6d6cb1..f4b0a07377 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 57529ae63d..df992490d5 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)
diff --git a/ws.c b/ws.c
index 760b5743fa..c0893386e6 100644
--- a/ws.c
+++ b/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;
}