2 * Handle git attributes. See gitattributes(5) for a description of
3 * the file syntax, and Documentation/technical/api-gitattributes.txt
4 * for a description of the API.
6 * One basic design decision here is that we are not going to support
7 * an insanely large number of attributes.
10 #define NO_THE_INDEX_COMPATIBILITY_MACROS
18 const char git_attr__true
[] = "(builtin)true";
19 const char git_attr__false
[] = "\0(builtin)false";
20 static const char git_attr__unknown
[] = "(builtin)unknown";
21 #define ATTR__TRUE git_attr__true
22 #define ATTR__FALSE git_attr__false
23 #define ATTR__UNSET NULL
24 #define ATTR__UNKNOWN git_attr__unknown
26 /* This is a randomly chosen prime. */
34 * NEEDSWORK: the global dictionary of the interned attributes
35 * must stay a singleton even after we become thread-ready.
36 * Access to these must be surrounded with mutex when it happens.
39 struct git_attr
*next
;
44 char name
[FLEX_ARRAY
];
47 static struct git_attr
*(git_attr_hash
[HASHSIZE
]);
50 * NEEDSWORK: maybe-real, maybe-macro are not property of
51 * an attribute, as it depends on what .gitattributes are
52 * read. Once we introduce per git_attr_check attr_stack
53 * and check_all_attr, the optimization based on them will
54 * become unnecessary and can go away. So is this variable.
56 static int cannot_trust_maybe_real
;
58 /* NEEDSWORK: This will become per git_attr_check */
59 static struct attr_check_item
*check_all_attr
;
61 const char *git_attr_name(const struct git_attr
*attr
)
66 static unsigned hash_name(const char *name
, int namelen
)
72 val
= ((val
<< 7) | (val
>> 22)) ^ c
;
77 static int attr_name_valid(const char *name
, size_t namelen
)
80 * Attribute name cannot begin with '-' and must consist of
81 * characters from [-A-Za-z0-9_.].
83 if (namelen
<= 0 || *name
== '-')
87 if (! (ch
== '-' || ch
== '.' || ch
== '_' ||
88 ('0' <= ch
&& ch
<= '9') ||
89 ('a' <= ch
&& ch
<= 'z') ||
90 ('A' <= ch
&& ch
<= 'Z')) )
96 static void report_invalid_attr(const char *name
, size_t len
,
97 const char *src
, int lineno
)
99 struct strbuf err
= STRBUF_INIT
;
100 strbuf_addf(&err
, _("%.*s is not a valid attribute name"),
102 fprintf(stderr
, "%s: %s:%d\n", err
.buf
, src
, lineno
);
103 strbuf_release(&err
);
106 static struct git_attr
*git_attr_internal(const char *name
, int len
)
108 unsigned hval
= hash_name(name
, len
);
109 unsigned pos
= hval
% HASHSIZE
;
112 for (a
= git_attr_hash
[pos
]; a
; a
= a
->next
) {
114 !memcmp(a
->name
, name
, len
) && !a
->name
[len
])
118 if (!attr_name_valid(name
, len
))
121 FLEX_ALLOC_MEM(a
, name
, name
, len
);
123 a
->next
= git_attr_hash
[pos
];
124 a
->attr_nr
= attr_nr
++;
127 git_attr_hash
[pos
] = a
;
130 * NEEDSWORK: per git_attr_check check_all_attr
131 * will be initialized a lot more lazily, not
132 * like this, and not here.
134 REALLOC_ARRAY(check_all_attr
, attr_nr
);
135 check_all_attr
[a
->attr_nr
].attr
= a
;
136 check_all_attr
[a
->attr_nr
].value
= ATTR__UNKNOWN
;
140 struct git_attr
*git_attr(const char *name
)
142 return git_attr_internal(name
, strlen(name
));
145 /* What does a matched pattern decide? */
147 struct git_attr
*attr
;
155 unsigned flags
; /* EXC_FLAG_* */
159 * One rule, as from a .gitattributes file.
161 * If is_macro is true, then u.attr is a pointer to the git_attr being
164 * If is_macro is false, then u.pat is the filename pattern to which the
167 * In either case, num_attr is the number of attributes affected by
168 * this rule, and state is an array listing them. The attributes are
169 * listed as they appear in the file (macros unexpanded).
174 struct git_attr
*attr
;
178 struct attr_state state
[FLEX_ARRAY
];
181 static const char blank
[] = " \t\r\n";
184 * Parse a whitespace-delimited attribute state (i.e., "attr",
185 * "-attr", "!attr", or "attr=value") from the string starting at src.
186 * If e is not NULL, write the results to *e. Return a pointer to the
187 * remainder of the string (with leading whitespace removed), or NULL
188 * if there was an error.
190 static const char *parse_attr(const char *src
, int lineno
, const char *cp
,
191 struct attr_state
*e
)
193 const char *ep
, *equals
;
196 ep
= cp
+ strcspn(cp
, blank
);
197 equals
= strchr(cp
, '=');
198 if (equals
&& ep
< equals
)
205 if (*cp
== '-' || *cp
== '!') {
209 if (!attr_name_valid(cp
, len
)) {
210 report_invalid_attr(cp
, len
, src
, lineno
);
215 * As this function is always called twice, once with
216 * e == NULL in the first pass and then e != NULL in
217 * the second pass, no need for attr_name_valid()
220 if (*cp
== '-' || *cp
== '!') {
221 e
->setto
= (*cp
== '-') ? ATTR__FALSE
: ATTR__UNSET
;
226 e
->setto
= ATTR__TRUE
;
228 e
->setto
= xmemdupz(equals
+ 1, ep
- equals
- 1);
230 e
->attr
= git_attr_internal(cp
, len
);
232 return ep
+ strspn(ep
, blank
);
235 static struct match_attr
*parse_attr_line(const char *line
, const char *src
,
236 int lineno
, int macro_ok
)
240 const char *cp
, *name
, *states
;
241 struct match_attr
*res
= NULL
;
243 struct strbuf pattern
= STRBUF_INIT
;
245 cp
= line
+ strspn(line
, blank
);
246 if (!*cp
|| *cp
== '#')
250 if (*cp
== '"' && !unquote_c_style(&pattern
, name
, &states
)) {
252 namelen
= pattern
.len
;
254 namelen
= strcspn(name
, blank
);
255 states
= name
+ namelen
;
258 if (strlen(ATTRIBUTE_MACRO_PREFIX
) < namelen
&&
259 starts_with(name
, ATTRIBUTE_MACRO_PREFIX
)) {
261 fprintf(stderr
, "%s not allowed: %s:%d\n",
266 name
+= strlen(ATTRIBUTE_MACRO_PREFIX
);
267 name
+= strspn(name
, blank
);
268 namelen
= strcspn(name
, blank
);
269 if (!attr_name_valid(name
, namelen
)) {
270 report_invalid_attr(name
, namelen
, src
, lineno
);
277 states
+= strspn(states
, blank
);
279 /* First pass to count the attr_states */
280 for (cp
= states
, num_attr
= 0; *cp
; num_attr
++) {
281 cp
= parse_attr(src
, lineno
, cp
, NULL
);
288 sizeof(struct attr_state
) * num_attr
+
289 (is_macro
? 0 : namelen
+ 1));
291 res
->u
.attr
= git_attr_internal(name
, namelen
);
292 res
->u
.attr
->maybe_macro
= 1;
294 char *p
= (char *)&(res
->state
[num_attr
]);
295 memcpy(p
, name
, namelen
);
296 res
->u
.pat
.pattern
= p
;
297 parse_exclude_pattern(&res
->u
.pat
.pattern
,
298 &res
->u
.pat
.patternlen
,
300 &res
->u
.pat
.nowildcardlen
);
301 if (res
->u
.pat
.flags
& EXC_FLAG_NEGATIVE
) {
302 warning(_("Negative patterns are ignored in git attributes\n"
303 "Use '\\!' for literal leading exclamation."));
307 res
->is_macro
= is_macro
;
308 res
->num_attr
= num_attr
;
310 /* Second pass to fill the attr_states */
311 for (cp
= states
, i
= 0; *cp
; i
++) {
312 cp
= parse_attr(src
, lineno
, cp
, &(res
->state
[i
]));
314 res
->state
[i
].attr
->maybe_real
= 1;
315 if (res
->state
[i
].attr
->maybe_macro
)
316 cannot_trust_maybe_real
= 1;
319 strbuf_release(&pattern
);
323 strbuf_release(&pattern
);
329 * Like info/exclude and .gitignore, the attribute information can
330 * come from many places.
332 * (1) .gitattribute file of the same directory;
333 * (2) .gitattribute file of the parent directory if (1) does not have
334 * any match; this goes recursively upwards, just like .gitignore.
335 * (3) $GIT_DIR/info/attributes, which overrides both of the above.
337 * In the same file, later entries override the earlier match, so in the
338 * global list, we would have entries from info/attributes the earliest
339 * (reading the file from top to bottom), .gitattribute of the root
340 * directory (again, reading the file from top to bottom) down to the
341 * current directory, and then scan the list backwards to find the first match.
342 * This is exactly the same as what is_excluded() does in dir.c to deal with
343 * .gitignore file and info/excludes file as a fallback.
346 /* NEEDSWORK: This will become per git_attr_check */
347 static struct attr_stack
{
348 struct attr_stack
*prev
;
351 unsigned num_matches
;
353 struct match_attr
**attrs
;
356 static void free_attr_elem(struct attr_stack
*e
)
360 for (i
= 0; i
< e
->num_matches
; i
++) {
361 struct match_attr
*a
= e
->attrs
[i
];
363 for (j
= 0; j
< a
->num_attr
; j
++) {
364 const char *setto
= a
->state
[j
].setto
;
365 if (setto
== ATTR__TRUE
||
366 setto
== ATTR__FALSE
||
367 setto
== ATTR__UNSET
||
368 setto
== ATTR__UNKNOWN
)
371 free((char *) setto
);
379 struct attr_check
*attr_check_alloc(void)
381 return xcalloc(1, sizeof(struct attr_check
));
384 struct attr_check
*attr_check_initl(const char *one
, ...)
386 struct attr_check
*check
;
391 va_start(params
, one
);
392 for (cnt
= 1; (param
= va_arg(params
, const char *)) != NULL
; cnt
++)
396 check
= attr_check_alloc();
399 check
->items
= xcalloc(cnt
, sizeof(struct attr_check_item
));
401 check
->items
[0].attr
= git_attr(one
);
402 va_start(params
, one
);
403 for (cnt
= 1; cnt
< check
->nr
; cnt
++) {
404 const struct git_attr
*attr
;
405 param
= va_arg(params
, const char *);
407 die("BUG: counted %d != ended at %d",
409 attr
= git_attr(param
);
411 die("BUG: %s: not a valid attribute name", param
);
412 check
->items
[cnt
].attr
= attr
;
418 struct attr_check_item
*attr_check_append(struct attr_check
*check
,
419 const struct git_attr
*attr
)
421 struct attr_check_item
*item
;
423 ALLOC_GROW(check
->items
, check
->nr
+ 1, check
->alloc
);
424 item
= &check
->items
[check
->nr
++];
429 void attr_check_reset(struct attr_check
*check
)
434 void attr_check_clear(struct attr_check
*check
)
442 void attr_check_free(struct attr_check
*check
)
444 attr_check_clear(check
);
448 static const char *builtin_attr
[] = {
449 "[attr]binary -diff -merge -text",
453 static void handle_attr_line(struct attr_stack
*res
,
459 struct match_attr
*a
;
461 a
= parse_attr_line(line
, src
, lineno
, macro_ok
);
464 ALLOC_GROW(res
->attrs
, res
->num_matches
+ 1, res
->alloc
);
465 res
->attrs
[res
->num_matches
++] = a
;
468 static struct attr_stack
*read_attr_from_array(const char **list
)
470 struct attr_stack
*res
;
474 res
= xcalloc(1, sizeof(*res
));
475 while ((line
= *(list
++)) != NULL
)
476 handle_attr_line(res
, line
, "[builtin]", ++lineno
, 1);
481 * NEEDSWORK: these two are tricky. The callers assume there is a
482 * single, system-wide global state "where we read attributes from?"
483 * and when the state is flipped by calling git_attr_set_direction(),
484 * attr_stack is discarded so that subsequent attr_check will lazily
485 * read from the right place. And they do not know or care who called
486 * by them uses the attribute subsystem, hence have no knowledge of
487 * existing git_attr_check instances or future ones that will be
490 * Probably we need a thread_local that holds these two variables,
491 * and a list of git_attr_check instances (which need to be maintained
492 * by hooking into git_attr_check_alloc(), git_attr_check_initl(), and
493 * git_attr_check_clear(). Then git_attr_set_direction() updates the
494 * fields in that thread_local for these two variables, iterate over
495 * all the active git_attr_check instances and discard the attr_stack
496 * they hold. Yuck, but it sounds doable.
498 static enum git_attr_direction direction
;
499 static struct index_state
*use_index
;
501 static struct attr_stack
*read_attr_from_file(const char *path
, int macro_ok
)
503 FILE *fp
= fopen(path
, "r");
504 struct attr_stack
*res
;
509 if (errno
!= ENOENT
&& errno
!= ENOTDIR
)
510 warn_on_inaccessible(path
);
513 res
= xcalloc(1, sizeof(*res
));
514 while (fgets(buf
, sizeof(buf
), fp
)) {
517 skip_utf8_bom(&bufp
, strlen(bufp
));
518 handle_attr_line(res
, bufp
, path
, ++lineno
, macro_ok
);
524 static struct attr_stack
*read_attr_from_index(const char *path
, int macro_ok
)
526 struct attr_stack
*res
;
530 buf
= read_blob_data_from_index(use_index
? use_index
: &the_index
, path
, NULL
);
534 res
= xcalloc(1, sizeof(*res
));
535 for (sp
= buf
; *sp
; ) {
539 ep
= strchrnul(sp
, '\n');
540 more
= (*ep
== '\n');
542 handle_attr_line(res
, sp
, path
, ++lineno
, macro_ok
);
549 static struct attr_stack
*read_attr(const char *path
, int macro_ok
)
551 struct attr_stack
*res
;
553 if (direction
== GIT_ATTR_CHECKOUT
) {
554 res
= read_attr_from_index(path
, macro_ok
);
556 res
= read_attr_from_file(path
, macro_ok
);
558 else if (direction
== GIT_ATTR_CHECKIN
) {
559 res
= read_attr_from_file(path
, macro_ok
);
562 * There is no checked out .gitattributes file there, but
563 * we might have it in the index. We allow operation in a
564 * sparsely checked out work tree, so read from it.
566 res
= read_attr_from_index(path
, macro_ok
);
569 res
= read_attr_from_index(path
, macro_ok
);
571 res
= xcalloc(1, sizeof(*res
));
576 static void debug_info(const char *what
, struct attr_stack
*elem
)
578 fprintf(stderr
, "%s: %s\n", what
, elem
->origin
? elem
->origin
: "()");
580 static void debug_set(const char *what
, const char *match
, struct git_attr
*attr
, const void *v
)
582 const char *value
= v
;
584 if (ATTR_TRUE(value
))
586 else if (ATTR_FALSE(value
))
588 else if (ATTR_UNSET(value
))
589 value
= "unspecified";
591 fprintf(stderr
, "%s: %s => %s (%s)\n",
592 what
, attr
->name
, (char *) value
, match
);
594 #define debug_push(a) debug_info("push", (a))
595 #define debug_pop(a) debug_info("pop", (a))
597 #define debug_push(a) do { ; } while (0)
598 #define debug_pop(a) do { ; } while (0)
599 #define debug_set(a,b,c,d) do { ; } while (0)
600 #endif /* DEBUG_ATTR */
602 static void drop_attr_stack(void)
605 struct attr_stack
*elem
= attr_stack
;
606 attr_stack
= elem
->prev
;
607 free_attr_elem(elem
);
611 static const char *git_etc_gitattributes(void)
613 static const char *system_wide
;
615 system_wide
= system_path(ETC_GITATTRIBUTES
);
619 static int git_attr_system(void)
621 return !git_env_bool("GIT_ATTR_NOSYSTEM", 0);
624 static GIT_PATH_FUNC(git_path_info_attributes
, INFOATTRIBUTES_FILE
)
626 static void push_stack(struct attr_stack
**attr_stack_p
,
627 struct attr_stack
*elem
, char *origin
, size_t originlen
)
630 elem
->origin
= origin
;
632 elem
->originlen
= originlen
;
633 elem
->prev
= *attr_stack_p
;
634 *attr_stack_p
= elem
;
638 static void bootstrap_attr_stack(void)
640 struct attr_stack
*elem
;
645 push_stack(&attr_stack
, read_attr_from_array(builtin_attr
), NULL
, 0);
647 if (git_attr_system())
648 push_stack(&attr_stack
,
649 read_attr_from_file(git_etc_gitattributes(), 1),
652 if (!git_attributes_file
)
653 git_attributes_file
= xdg_config_home("attributes");
654 if (git_attributes_file
)
655 push_stack(&attr_stack
,
656 read_attr_from_file(git_attributes_file
, 1),
659 if (!is_bare_repository() || direction
== GIT_ATTR_INDEX
) {
660 elem
= read_attr(GITATTRIBUTES_FILE
, 1);
661 push_stack(&attr_stack
, elem
, xstrdup(""), 0);
665 if (startup_info
->have_repository
)
666 elem
= read_attr_from_file(git_path_info_attributes(), 1);
671 elem
= xcalloc(1, sizeof(*elem
));
672 push_stack(&attr_stack
, elem
, NULL
, 0);
675 static void prepare_attr_stack(const char *path
, int dirlen
)
677 struct attr_stack
*elem
, *info
;
681 * At the bottom of the attribute stack is the built-in
682 * set of attribute definitions, followed by the contents
683 * of $(prefix)/etc/gitattributes and a file specified by
684 * core.attributesfile. Then, contents from
685 * .gitattribute files from directories closer to the
686 * root to the ones in deeper directories are pushed
687 * to the stack. Finally, at the very top of the stack
688 * we always keep the contents of $GIT_DIR/info/attributes.
690 * When checking, we use entries from near the top of the
691 * stack, preferring $GIT_DIR/info/attributes, then
692 * .gitattributes in deeper directories to shallower ones,
693 * and finally use the built-in set as the default.
695 bootstrap_attr_stack();
698 * Pop the "info" one that is always at the top of the stack.
701 attr_stack
= info
->prev
;
704 * Pop the ones from directories that are not the prefix of
705 * the path we are checking. Break out of the loop when we see
706 * the root one (whose origin is an empty string "") or the builtin
707 * one (whose origin is NULL) without popping it.
709 while (attr_stack
->origin
) {
710 int namelen
= strlen(attr_stack
->origin
);
713 if (namelen
<= dirlen
&&
714 !strncmp(elem
->origin
, path
, namelen
) &&
715 (!namelen
|| path
[namelen
] == '/'))
719 attr_stack
= elem
->prev
;
720 free_attr_elem(elem
);
724 * Read from parent directories and push them down
726 if (!is_bare_repository() || direction
== GIT_ATTR_INDEX
) {
728 * bootstrap_attr_stack() should have added, and the
729 * above loop should have stopped before popping, the
730 * root element whose attr_stack->origin is set to an
733 struct strbuf pathbuf
= STRBUF_INIT
;
735 assert(attr_stack
->origin
);
737 size_t len
= strlen(attr_stack
->origin
);
742 cp
= memchr(path
+ len
+ 1, '/', dirlen
- len
- 1);
745 strbuf_addf(&pathbuf
,
746 "%.*s/%s", (int)(cp
- path
), path
,
748 elem
= read_attr(pathbuf
.buf
, 0);
749 strbuf_setlen(&pathbuf
, cp
- path
);
750 origin
= strbuf_detach(&pathbuf
, &len
);
751 push_stack(&attr_stack
, elem
, origin
, len
);
755 strbuf_release(&pathbuf
);
759 * Finally push the "info" one at the top of the stack.
761 push_stack(&attr_stack
, info
, NULL
, 0);
764 static int path_matches(const char *pathname
, int pathlen
,
766 const struct pattern
*pat
,
767 const char *base
, int baselen
)
769 const char *pattern
= pat
->pattern
;
770 int prefix
= pat
->nowildcardlen
;
771 int isdir
= (pathlen
&& pathname
[pathlen
- 1] == '/');
773 if ((pat
->flags
& EXC_FLAG_MUSTBEDIR
) && !isdir
)
776 if (pat
->flags
& EXC_FLAG_NODIR
) {
777 return match_basename(pathname
+ basename_offset
,
778 pathlen
- basename_offset
- isdir
,
780 pat
->patternlen
, pat
->flags
);
782 return match_pathname(pathname
, pathlen
- isdir
,
784 pattern
, prefix
, pat
->patternlen
, pat
->flags
);
787 static int macroexpand_one(int attr_nr
, int rem
);
789 static int fill_one(const char *what
, struct match_attr
*a
, int rem
)
791 struct attr_check_item
*check
= check_all_attr
;
794 for (i
= a
->num_attr
- 1; 0 < rem
&& 0 <= i
; i
--) {
795 struct git_attr
*attr
= a
->state
[i
].attr
;
796 const char **n
= &(check
[attr
->attr_nr
].value
);
797 const char *v
= a
->state
[i
].setto
;
799 if (*n
== ATTR__UNKNOWN
) {
801 a
->is_macro
? a
->u
.attr
->name
: a
->u
.pat
.pattern
,
805 rem
= macroexpand_one(attr
->attr_nr
, rem
);
811 static int fill(const char *path
, int pathlen
, int basename_offset
,
812 struct attr_stack
*stk
, int rem
)
815 const char *base
= stk
->origin
? stk
->origin
: "";
817 for (i
= stk
->num_matches
- 1; 0 < rem
&& 0 <= i
; i
--) {
818 struct match_attr
*a
= stk
->attrs
[i
];
821 if (path_matches(path
, pathlen
, basename_offset
,
822 &a
->u
.pat
, base
, stk
->originlen
))
823 rem
= fill_one("fill", a
, rem
);
828 static int macroexpand_one(int nr
, int rem
)
830 struct attr_stack
*stk
;
833 if (check_all_attr
[nr
].value
!= ATTR__TRUE
||
834 !check_all_attr
[nr
].attr
->maybe_macro
)
837 for (stk
= attr_stack
; stk
; stk
= stk
->prev
) {
838 for (i
= stk
->num_matches
- 1; 0 <= i
; i
--) {
839 struct match_attr
*ma
= stk
->attrs
[i
];
842 if (ma
->u
.attr
->attr_nr
== nr
)
843 return fill_one("expand", ma
, rem
);
851 * Collect attributes for path into the array pointed to by
852 * check_all_attr. If num is non-zero, only attributes in check[] are
853 * collected. Otherwise all attributes are collected.
855 static void collect_some_attrs(const char *path
, struct attr_check
*check
)
857 struct attr_stack
*stk
;
858 int i
, pathlen
, rem
, dirlen
;
859 const char *cp
, *last_slash
= NULL
;
862 for (cp
= path
; *cp
; cp
++) {
863 if (*cp
== '/' && cp
[1])
868 basename_offset
= last_slash
+ 1 - path
;
869 dirlen
= last_slash
- path
;
875 prepare_attr_stack(path
, dirlen
);
876 for (i
= 0; i
< attr_nr
; i
++)
877 check_all_attr
[i
].value
= ATTR__UNKNOWN
;
878 if (check
->nr
&& !cannot_trust_maybe_real
) {
880 for (i
= 0; i
< check
->nr
; i
++) {
881 const struct git_attr
*a
= check
->items
[i
].attr
;
882 if (!a
->maybe_real
) {
883 struct attr_check_item
*c
;
884 c
= check_all_attr
+ a
->attr_nr
;
885 c
->value
= ATTR__UNSET
;
889 if (rem
== check
->nr
)
894 for (stk
= attr_stack
; 0 < rem
&& stk
; stk
= stk
->prev
)
895 rem
= fill(path
, pathlen
, basename_offset
, stk
, rem
);
898 int git_check_attr(const char *path
, struct attr_check
*check
)
902 collect_some_attrs(path
, check
);
904 for (i
= 0; i
< check
->nr
; i
++) {
905 const char *value
= check_all_attr
[check
->items
[i
].attr
->attr_nr
].value
;
906 if (value
== ATTR__UNKNOWN
)
908 check
->items
[i
].value
= value
;
914 void git_all_attrs(const char *path
, struct attr_check
*check
)
918 attr_check_reset(check
);
919 collect_some_attrs(path
, check
);
921 for (i
= 0; i
< attr_nr
; i
++) {
922 const char *name
= check_all_attr
[i
].attr
->name
;
923 const char *value
= check_all_attr
[i
].value
;
924 struct attr_check_item
*item
;
925 if (value
== ATTR__UNSET
|| value
== ATTR__UNKNOWN
)
927 item
= attr_check_append(check
, git_attr(name
));
932 void git_attr_set_direction(enum git_attr_direction
new, struct index_state
*istate
)
934 enum git_attr_direction old
= direction
;
936 if (is_bare_repository() && new != GIT_ATTR_INDEX
)
937 die("BUG: non-INDEX attr direction in a bare repo");