From: Junio C Hamano Date: Tue, 5 Feb 2019 22:26:16 +0000 (-0800) Subject: Merge branch 'jk/attr-macro-fix' X-Git-Tag: v2.21.0-rc0~40 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/02bf766cc5d7580ce17dfab36fce976bfd06585b?hp=-c Merge branch 'jk/attr-macro-fix' Asking "git check-attr" about a macro (e.g. "binary") on a specific path did not work correctly, even though "git check-attr -a" listed such a macro correctly. This has been corrected. * jk/attr-macro-fix: attr: do not mark queried macros as unset --- 02bf766cc5d7580ce17dfab36fce976bfd06585b diff --combined attr.c index b63fe0fc0e,293755226c..0cba789129 --- a/attr.c +++ b/attr.c @@@ -41,17 -41,23 +41,17 @@@ const char *git_attr_name(const struct struct attr_hashmap { struct hashmap map; -#ifndef NO_PTHREADS pthread_mutex_t mutex; -#endif }; static inline void hashmap_lock(struct attr_hashmap *map) { -#ifndef NO_PTHREADS pthread_mutex_lock(&map->mutex); -#endif } static inline void hashmap_unlock(struct attr_hashmap *map) { -#ifndef NO_PTHREADS pthread_mutex_unlock(&map->mutex); -#endif } /* @@@ -366,8 -372,8 +366,8 @@@ static struct match_attr *parse_attr_li if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen && starts_with(name, ATTRIBUTE_MACRO_PREFIX)) { if (!macro_ok) { - fprintf(stderr, "%s not allowed: %s:%d\n", - name, src, lineno); + fprintf_ln(stderr, _("%s not allowed: %s:%d"), + name, src, lineno); goto fail_return; } is_macro = 1; @@@ -492,17 -498,23 +492,17 @@@ static struct check_vector size_t nr; size_t alloc; struct attr_check **checks; -#ifndef NO_PTHREADS pthread_mutex_t mutex; -#endif } check_vector; static inline void vector_lock(void) { -#ifndef NO_PTHREADS pthread_mutex_lock(&check_vector.mutex); -#endif } static inline void vector_unlock(void) { -#ifndef NO_PTHREADS pthread_mutex_unlock(&check_vector.mutex); -#endif } static void check_vector_add(struct attr_check *c) @@@ -1092,7 -1104,7 +1092,7 @@@ static void collect_some_attrs(const st const char *path, struct attr_check *check) { - int i, pathlen, rem, dirlen; + int pathlen, rem, dirlen; const char *cp, *last_slash = NULL; int basename_offset; @@@ -1113,20 -1125,6 +1113,6 @@@ all_attrs_init(&g_attr_hashmap, check); determine_macros(check->all_attrs, check->stack); - if (check->nr) { - rem = 0; - for (i = 0; i < check->nr; i++) { - int n = check->items[i].attr->attr_nr; - struct all_attrs_item *item = &check->all_attrs[n]; - if (item->macro) { - item->value = ATTR__UNSET; - rem++; - } - } - if (rem == check->nr) - return; - } - rem = check->all_attrs_nr; fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem); } @@@ -1169,6 -1167,8 +1155,6 @@@ void git_all_attrs(const struct index_s void attr_start(void) { -#ifndef NO_PTHREADS pthread_mutex_init(&g_attr_hashmap.mutex, NULL); pthread_mutex_init(&check_vector.mutex, NULL); -#endif }