Skip to content

Commit 7bd1805

Browse files
committed
attr: rename function and struct related to checking attributes
The traditional API to check attributes is to prepare an N-element array of "struct git_attr_check" and pass N and the array to the function "git_check_attr()" as arguments. In preparation to revamp the API to pass a single structure, in which these N elements are held, rename the type used for these individual array elements to "struct attr_check_item" and rename the function to "git_check_attrs()". Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d42ec5 commit 7bd1805

File tree

9 files changed

+42
-41
lines changed

9 files changed

+42
-41
lines changed

archive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void *sha1_file_to_archive(const struct archiver_args *args,
8787
return buffer;
8888
}
8989

90-
static void setup_archive_check(struct git_attr_check *check)
90+
static void setup_archive_check(struct attr_check_item *check)
9191
{
9292
static struct git_attr *attr_export_ignore;
9393
static struct git_attr *attr_export_subst;
@@ -123,7 +123,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
123123
struct archiver_context *c = context;
124124
struct archiver_args *args = c->args;
125125
write_archive_entry_fn_t write_entry = c->write_entry;
126-
struct git_attr_check check[2];
126+
struct attr_check_item check[2];
127127
const char *path_without_prefix;
128128
int err;
129129

@@ -138,7 +138,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
138138
path_without_prefix = path.buf + args->baselen;
139139

140140
setup_archive_check(check);
141-
if (!git_check_attr(path_without_prefix, ARRAY_SIZE(check), check)) {
141+
if (!git_check_attrs(path_without_prefix, ARRAY_SIZE(check), check)) {
142142
if (ATTR_TRUE(check[0].value))
143143
return 0;
144144
args->convert = ATTR_TRUE(check[1].value);

attr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static struct git_attr *(git_attr_hash[HASHSIZE]);
5656
static int cannot_trust_maybe_real;
5757

5858
/* NEEDSWORK: This will become per git_attr_check */
59-
static struct git_attr_check *check_all_attr;
59+
static struct attr_check_item *check_all_attr;
6060

6161
const char *git_attr_name(const struct git_attr *attr)
6262
{
@@ -713,7 +713,7 @@ static int macroexpand_one(int attr_nr, int rem);
713713

714714
static int fill_one(const char *what, struct match_attr *a, int rem)
715715
{
716-
struct git_attr_check *check = check_all_attr;
716+
struct attr_check_item *check = check_all_attr;
717717
int i;
718718

719719
for (i = a->num_attr - 1; 0 < rem && 0 <= i; i--) {
@@ -778,7 +778,7 @@ static int macroexpand_one(int nr, int rem)
778778
* collected. Otherwise all attributes are collected.
779779
*/
780780
static void collect_some_attrs(const char *path, int num,
781-
struct git_attr_check *check)
781+
struct attr_check_item *check)
782782

783783
{
784784
struct attr_stack *stk;
@@ -806,7 +806,7 @@ static void collect_some_attrs(const char *path, int num,
806806
rem = 0;
807807
for (i = 0; i < num; i++) {
808808
if (!check[i].attr->maybe_real) {
809-
struct git_attr_check *c;
809+
struct attr_check_item *c;
810810
c = check_all_attr + check[i].attr->attr_nr;
811811
c->value = ATTR__UNSET;
812812
rem++;
@@ -821,7 +821,7 @@ static void collect_some_attrs(const char *path, int num,
821821
rem = fill(path, pathlen, basename_offset, stk, rem);
822822
}
823823

824-
int git_check_attr(const char *path, int num, struct git_attr_check *check)
824+
int git_check_attrs(const char *path, int num, struct attr_check_item *check)
825825
{
826826
int i;
827827

@@ -837,7 +837,7 @@ int git_check_attr(const char *path, int num, struct git_attr_check *check)
837837
return 0;
838838
}
839839

840-
int git_all_attrs(const char *path, int *num, struct git_attr_check **check)
840+
int git_all_attrs(const char *path, int *num, struct attr_check_item **check)
841841
{
842842
int i, count, j;
843843

attr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ extern const char git_attr__false[];
2020
#define ATTR_UNSET(v) ((v) == NULL)
2121

2222
/*
23-
* Send one or more git_attr_check to git_check_attr(), and
23+
* Send one or more git_attr_check to git_check_attrs(), and
2424
* each 'value' member tells what its value is.
2525
* Unset one is returned as NULL.
2626
*/
27-
struct git_attr_check {
27+
struct attr_check_item {
2828
const struct git_attr *attr;
2929
const char *value;
3030
};
@@ -36,7 +36,7 @@ struct git_attr_check {
3636
*/
3737
extern const char *git_attr_name(const struct git_attr *);
3838

39-
int git_check_attr(const char *path, int, struct git_attr_check *);
39+
int git_check_attrs(const char *path, int, struct attr_check_item *);
4040

4141
/*
4242
* Retrieve all attributes that apply to the specified path. *num
@@ -45,7 +45,7 @@ int git_check_attr(const char *path, int, struct git_attr_check *);
4545
* objects describing the attributes and their values. *check must be
4646
* free()ed by the caller.
4747
*/
48-
int git_all_attrs(const char *path, int *num, struct git_attr_check **check);
48+
int git_all_attrs(const char *path, int *num, struct attr_check_item **check);
4949

5050
enum git_attr_direction {
5151
GIT_ATTR_CHECKIN,

builtin/check-attr.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ static const struct option check_attr_options[] = {
2424
OPT_END()
2525
};
2626

27-
static void output_attr(int cnt, struct git_attr_check *check,
28-
const char *file)
27+
static void output_attr(int cnt, struct attr_check_item *check,
28+
const char *file)
2929
{
3030
int j;
3131
for (j = 0; j < cnt; j++) {
@@ -51,14 +51,15 @@ static void output_attr(int cnt, struct git_attr_check *check,
5151
}
5252
}
5353

54-
static void check_attr(const char *prefix, int cnt,
55-
struct git_attr_check *check, const char *file)
54+
static void check_attr(const char *prefix,
55+
int cnt, struct attr_check_item *check,
56+
const char *file)
5657
{
5758
char *full_path =
5859
prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
5960
if (check != NULL) {
60-
if (git_check_attr(full_path, cnt, check))
61-
die("git_check_attr died");
61+
if (git_check_attrs(full_path, cnt, check))
62+
die("git_check_attrs died");
6263
output_attr(cnt, check, file);
6364
} else {
6465
if (git_all_attrs(full_path, &cnt, &check))
@@ -69,8 +70,8 @@ static void check_attr(const char *prefix, int cnt,
6970
free(full_path);
7071
}
7172

72-
static void check_attr_stdin_paths(const char *prefix, int cnt,
73-
struct git_attr_check *check)
73+
static void check_attr_stdin_paths(const char *prefix,
74+
int cnt, struct attr_check_item *check)
7475
{
7576
struct strbuf buf = STRBUF_INIT;
7677
struct strbuf unquoted = STRBUF_INIT;
@@ -99,7 +100,7 @@ static NORETURN void error_with_usage(const char *msg)
99100

100101
int cmd_check_attr(int argc, const char **argv, const char *prefix)
101102
{
102-
struct git_attr_check *check;
103+
struct attr_check_item *check;
103104
int cnt, i, doubledash, filei;
104105

105106
if (!is_bare_repository())

builtin/pack-objects.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ static void write_pack_file(void)
894894
written, nr_result);
895895
}
896896

897-
static void setup_delta_attr_check(struct git_attr_check *check)
897+
static void setup_delta_attr_check(struct attr_check_item *check)
898898
{
899899
static struct git_attr *attr_delta;
900900

@@ -906,10 +906,10 @@ static void setup_delta_attr_check(struct git_attr_check *check)
906906

907907
static int no_try_delta(const char *path)
908908
{
909-
struct git_attr_check check[1];
909+
struct attr_check_item check[1];
910910

911911
setup_delta_attr_check(check);
912-
if (git_check_attr(path, ARRAY_SIZE(check), check))
912+
if (git_check_attrs(path, ARRAY_SIZE(check), check))
913913
return 0;
914914
if (ATTR_FALSE(check->value))
915915
return 1;

convert.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
10281028
return 1;
10291029
}
10301030

1031-
static enum crlf_action git_path_check_crlf(struct git_attr_check *check)
1031+
static enum crlf_action git_path_check_crlf(struct attr_check_item *check)
10321032
{
10331033
const char *value = check->value;
10341034

@@ -1045,7 +1045,7 @@ static enum crlf_action git_path_check_crlf(struct git_attr_check *check)
10451045
return CRLF_UNDEFINED;
10461046
}
10471047

1048-
static enum eol git_path_check_eol(struct git_attr_check *check)
1048+
static enum eol git_path_check_eol(struct attr_check_item *check)
10491049
{
10501050
const char *value = check->value;
10511051

@@ -1058,7 +1058,7 @@ static enum eol git_path_check_eol(struct git_attr_check *check)
10581058
return EOL_UNSET;
10591059
}
10601060

1061-
static struct convert_driver *git_path_check_convert(struct git_attr_check *check)
1061+
static struct convert_driver *git_path_check_convert(struct attr_check_item *check)
10621062
{
10631063
const char *value = check->value;
10641064
struct convert_driver *drv;
@@ -1071,7 +1071,7 @@ static struct convert_driver *git_path_check_convert(struct git_attr_check *chec
10711071
return NULL;
10721072
}
10731073

1074-
static int git_path_check_ident(struct git_attr_check *check)
1074+
static int git_path_check_ident(struct attr_check_item *check)
10751075
{
10761076
const char *value = check->value;
10771077

@@ -1093,7 +1093,7 @@ static const char *conv_attr_name[] = {
10931093
static void convert_attrs(struct conv_attrs *ca, const char *path)
10941094
{
10951095
int i;
1096-
static struct git_attr_check ccheck[NUM_CONV_ATTRS];
1096+
static struct attr_check_item ccheck[NUM_CONV_ATTRS];
10971097

10981098
if (!ccheck[0].attr) {
10991099
for (i = 0; i < NUM_CONV_ATTRS; i++)
@@ -1102,7 +1102,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
11021102
git_config(read_convert_config, NULL);
11031103
}
11041104

1105-
if (!git_check_attr(path, NUM_CONV_ATTRS, ccheck)) {
1105+
if (!git_check_attrs(path, NUM_CONV_ATTRS, ccheck)) {
11061106
ca->crlf_action = git_path_check_crlf(ccheck + 4);
11071107
if (ca->crlf_action == CRLF_UNDEFINED)
11081108
ca->crlf_action = git_path_check_crlf(ccheck + 0);

ll-merge.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
336336
return &ll_merge_drv[LL_TEXT_MERGE];
337337
}
338338

339-
static int git_path_check_merge(const char *path, struct git_attr_check check[2])
339+
static int git_path_check_merge(const char *path, struct attr_check_item check[2])
340340
{
341341
if (!check[0].attr) {
342342
check[0].attr = git_attr("merge");
343343
check[1].attr = git_attr("conflict-marker-size");
344344
}
345-
return git_check_attr(path, 2, check);
345+
return git_check_attrs(path, 2, check);
346346
}
347347

348348
static void normalize_file(mmfile_t *mm, const char *path)
@@ -362,7 +362,7 @@ int ll_merge(mmbuffer_t *result_buf,
362362
mmfile_t *theirs, const char *their_label,
363363
const struct ll_merge_options *opts)
364364
{
365-
static struct git_attr_check check[2];
365+
static struct attr_check_item check[2];
366366
static const struct ll_merge_options default_opts;
367367
const char *ll_driver_name = NULL;
368368
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
@@ -398,12 +398,12 @@ int ll_merge(mmbuffer_t *result_buf,
398398

399399
int ll_merge_marker_size(const char *path)
400400
{
401-
static struct git_attr_check check;
401+
static struct attr_check_item check;
402402
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
403403

404404
if (!check.attr)
405405
check.attr = git_attr("conflict-marker-size");
406-
if (!git_check_attr(path, 1, &check) && check.value) {
406+
if (!git_check_attrs(path, 1, &check) && check.value) {
407407
marker_size = atoi(check.value);
408408
if (marker_size <= 0)
409409
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;

userdiff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ struct userdiff_driver *userdiff_find_by_name(const char *name) {
263263
struct userdiff_driver *userdiff_find_by_path(const char *path)
264264
{
265265
static struct git_attr *attr;
266-
struct git_attr_check check;
266+
struct attr_check_item check;
267267

268268
if (!attr)
269269
attr = git_attr("diff");
270270
check.attr = attr;
271271

272272
if (!path)
273273
return NULL;
274-
if (git_check_attr(path, 1, &check))
274+
if (git_check_attrs(path, 1, &check))
275275
return NULL;
276276

277277
if (ATTR_TRUE(check.value))

ws.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ unsigned parse_whitespace_rule(const char *string)
7171
return rule;
7272
}
7373

74-
static void setup_whitespace_attr_check(struct git_attr_check *check)
74+
static void setup_whitespace_attr_check(struct attr_check_item *check)
7575
{
7676
static struct git_attr *attr_whitespace;
7777

@@ -82,10 +82,10 @@ static void setup_whitespace_attr_check(struct git_attr_check *check)
8282

8383
unsigned whitespace_rule(const char *pathname)
8484
{
85-
struct git_attr_check attr_whitespace_rule;
85+
struct attr_check_item attr_whitespace_rule;
8686

8787
setup_whitespace_attr_check(&attr_whitespace_rule);
88-
if (!git_check_attr(pathname, 1, &attr_whitespace_rule)) {
88+
if (!git_check_attrs(pathname, 1, &attr_whitespace_rule)) {
8989
const char *value;
9090

9191
value = attr_whitespace_rule.value;

0 commit comments

Comments
 (0)