- if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
- /*
- * bootstrap_attr_stack() should have added, and the
- * above loop should have stopped before popping, the
- * root element whose attr_stack->origin is set to an
- * empty string.
- */
- struct strbuf pathbuf = STRBUF_INIT;
-
- assert((*stack)->origin);
- strbuf_addstr(&pathbuf, (*stack)->origin);
- /* Build up to the directory 'path' is in */
- while (pathbuf.len < dirlen) {
- size_t len = pathbuf.len;
- struct attr_stack *next;
- char *origin;
-
- /* Skip path-separator */
- if (len < dirlen && is_dir_sep(path[len]))
- len++;
- /* Find the end of the next component */
- while (len < dirlen && !is_dir_sep(path[len]))
- len++;
-
- if (pathbuf.len > 0)
- strbuf_addch(&pathbuf, '/');
- strbuf_add(&pathbuf, path + pathbuf.len,
- (len - pathbuf.len));
- strbuf_addf(&pathbuf, "/%s", GITATTRIBUTES_FILE);
-
- next = read_attr(pathbuf.buf, 0);
-
- /* reset the pathbuf to not include "/.gitattributes" */
- strbuf_setlen(&pathbuf, len);
-
- origin = xstrdup(pathbuf.buf);
- push_stack(stack, next, origin, len);
-
- }
- strbuf_release(&pathbuf);
+ assert((*stack)->origin);
+
+ strbuf_addstr(&pathbuf, (*stack)->origin);
+ /* Build up to the directory 'path' is in */
+ while (pathbuf.len < dirlen) {
+ size_t len = pathbuf.len;
+ struct attr_stack *next;
+ char *origin;
+
+ /* Skip path-separator */
+ if (len < dirlen && is_dir_sep(path[len]))
+ len++;
+ /* Find the end of the next component */
+ while (len < dirlen && !is_dir_sep(path[len]))
+ len++;
+
+ if (pathbuf.len > 0)
+ strbuf_addch(&pathbuf, '/');
+ strbuf_add(&pathbuf, path + pathbuf.len, (len - pathbuf.len));
+ strbuf_addf(&pathbuf, "/%s", GITATTRIBUTES_FILE);
+
+ next = read_attr(pathbuf.buf, 0);
+
+ /* reset the pathbuf to not include "/.gitattributes" */
+ strbuf_setlen(&pathbuf, len);
+
+ origin = xstrdup(pathbuf.buf);
+ push_stack(stack, next, origin, len);