static unsigned hash_name(const char *name, int namelen)
{
- unsigned val = 0;
- unsigned char c;
+ unsigned val = 0, c;
while (namelen--) {
c = *name++;
if (is_macro)
res->u.attr = git_attr(name, namelen);
else {
- res->u.pattern = (char*)&(res->state[num_attr]);
+ res->u.pattern = (char *)&(res->state[num_attr]);
memcpy(res->u.pattern, name, namelen);
res->u.pattern[namelen] = 0;
}
setto == ATTR__UNKNOWN)
;
else
- free((char*) setto);
+ free((char *) setto);
}
free(a);
}
if (!res)
res = read_attr_from_file(path, macro_ok);
}
- else {
+ else if (direction == GIT_ATTR_CHECKIN) {
res = read_attr_from_file(path, macro_ok);
if (!res)
/*
*/
res = read_attr_from_index(path, macro_ok);
}
+ else
+ res = read_attr_from_index(path, macro_ok);
if (!res)
res = xcalloc(1, sizeof(*res));
return res;
elem->prev = attr_stack;
attr_stack = elem;
- if (!is_bare_repository()) {
+ if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
elem = read_attr(GITATTRIBUTES_FILE, 1);
elem->origin = strdup("");
elem->prev = attr_stack;
/*
* Read from parent directories and push them down
*/
- if (!is_bare_repository()) {
+ if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
while (1) {
char *cp;
}
}
+ strbuf_release(&pathbuf);
+
/*
* Finally push the "info" one at the top of the stack.
*/
void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
{
enum git_attr_direction old = direction;
+
+ if (is_bare_repository() && new != GIT_ATTR_INDEX)
+ die("BUG: non-INDEX attr direction in a bare repo");
+
direction = new;
if (new != old)
drop_attr_stack();