Make git_check_attr() a void function
git_check_attr() returns always 0. Remove all the error handling code of the callers, which is never executed. Change git_check_attr() to be a void function. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Torsten Bögershausen committed
Sep 12, 2018 at 21:32 UTC
d64324cb60e4d0e1f5fdc1d3319c79ddbf5d0eb2
9 files changed
+57
-69
archive.c
+2
-1
@@ -110,7 +110,8 @@ static const struct attr_check *get_archive_attrs(struct index_state *istate,
110
static struct attr_check *check;
111
if (!check)
112
check = attr_check_initl("export-ignore", "export-subst", NULL);
113
- return git_check_attr(istate, path, check) ? NULL : check;
113
+ git_check_attr(istate, path, check);
114
+ return check;
115
}
116
117
static int check_attr_export_ignore(const struct attr_check *check)
attr.c
+3
-5
@@ -1143,9 +1143,9 @@ static void collect_some_attrs(const struct index_state *istate,
1143
fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
1144
}
1145
1146
-int git_check_attr(const struct index_state *istate,
1147
- const char *path,
1148
- struct attr_check *check)
1146
+void git_check_attr(const struct index_state *istate,
1147
+ const char *path,
1148
+ struct attr_check *check)
1149
{
1150
int i;
1151
@@ -1158,8 +1158,6 @@ int git_check_attr(const struct index_state *istate,
1158
value = ATTR__UNSET;
1159
check->items[i].value = value;
1160
}
1161
-
1162
- return 0;
1161
}
1162
1163
void git_all_attrs(const struct index_state *istate,
attr.h
+2
-2
@@ -63,8 +63,8 @@ void attr_check_free(struct attr_check *check);
63
*/
64
const char *git_attr_name(const struct git_attr *);
65
66
-int git_check_attr(const struct index_state *istate,
67
- const char *path, struct attr_check *check);
66
+void git_check_attr(const struct index_state *istate,
67
+ const char *path, struct attr_check *check);
68
69
/*
70
* Retrieve all attributes that apply to the specified path.
builtin/check-attr.c
+1
-2
@@ -65,8 +65,7 @@ static void check_attr(const char *prefix,
65
if (collect_all) {
66
git_all_attrs(&the_index, full_path, check);
67
} else {
68
- if (git_check_attr(&the_index, full_path, check))
69
- die("git_check_attr died");
68
+ git_check_attr(&the_index, full_path, check);
69
}
70
output_attr(check, file);
71
builtin/pack-objects.c
+1
-2
@@ -951,8 +951,7 @@ static int no_try_delta(const char *path)
951
952
if (!check)
953
check = attr_check_initl("delta", NULL);
954
- if (git_check_attr(&the_index, path, check))
955
- return 0;
954
+ git_check_attr(&the_index, path, check);
955
if (ATTR_FALSE(check->items[0].value))
956
return 1;
957
return 0;
convert.c
+19
-23
@@ -1297,6 +1297,7 @@ static void convert_attrs(const struct index_state *istate,
1297
struct conv_attrs *ca, const char *path)
1298
{
1299
static struct attr_check *check;
1300
+ struct attr_check_item *ccheck = NULL;
1301
1302
if (!check) {
1303
check = attr_check_initl("crlf", "ident", "filter",
@@ -1306,30 +1307,25 @@ static void convert_attrs(const struct index_state *istate,
1307
git_config(read_convert_config, NULL);
1308
}
1309
1309
- if (!git_check_attr(istate, path, check)) {
1310
- struct attr_check_item *ccheck = check->items;
1311
- ca->crlf_action = git_path_check_crlf(ccheck + 4);
1312
- if (ca->crlf_action == CRLF_UNDEFINED)
1313
- ca->crlf_action = git_path_check_crlf(ccheck + 0);
1314
- ca->ident = git_path_check_ident(ccheck + 1);
1315
- ca->drv = git_path_check_convert(ccheck + 2);
1316
- if (ca->crlf_action != CRLF_BINARY) {
1317
- enum eol eol_attr = git_path_check_eol(ccheck + 3);
1318
- if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_LF)
1319
- ca->crlf_action = CRLF_AUTO_INPUT;
1320
- else if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_CRLF)
1321
- ca->crlf_action = CRLF_AUTO_CRLF;
1322
- else if (eol_attr == EOL_LF)
1323
- ca->crlf_action = CRLF_TEXT_INPUT;
1324
- else if (eol_attr == EOL_CRLF)
1325
- ca->crlf_action = CRLF_TEXT_CRLF;
1326
- }
1327
- ca->working_tree_encoding = git_path_check_encoding(ccheck + 5);
1328
- } else {
1329
- ca->drv = NULL;
1330
- ca->crlf_action = CRLF_UNDEFINED;
1331
- ca->ident = 0;
1310
+ git_check_attr(istate, path, check);
1311
+ ccheck = check->items;
1312
+ ca->crlf_action = git_path_check_crlf(ccheck + 4);
1313
+ if (ca->crlf_action == CRLF_UNDEFINED)
1314
+ ca->crlf_action = git_path_check_crlf(ccheck + 0);
1315
+ ca->ident = git_path_check_ident(ccheck + 1);
1316
+ ca->drv = git_path_check_convert(ccheck + 2);
1317
+ if (ca->crlf_action != CRLF_BINARY) {
1318
+ enum eol eol_attr = git_path_check_eol(ccheck + 3);
1319
+ if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_LF)
1320
+ ca->crlf_action = CRLF_AUTO_INPUT;
1321
+ else if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_CRLF)
1322
+ ca->crlf_action = CRLF_AUTO_CRLF;
1323
+ else if (eol_attr == EOL_LF)
1324
+ ca->crlf_action = CRLF_TEXT_INPUT;
1325
+ else if (eol_attr == EOL_CRLF)
1326
+ ca->crlf_action = CRLF_TEXT_CRLF;
1327
}
1328
+ ca->working_tree_encoding = git_path_check_encoding(ccheck + 5);
1329
1330
/* Save attr and make a decision for action */
1331
ca->attr_action = ca->crlf_action;
ll-merge.c
+8
-8
@@ -371,13 +371,12 @@ int ll_merge(mmbuffer_t *result_buf,
371
if (!check)
372
check = attr_check_initl("merge", "conflict-marker-size", NULL);
373
374
- if (!git_check_attr(&the_index, path, check)) {
375
- ll_driver_name = check->items[0].value;
376
- if (check->items[1].value) {
377
- marker_size = atoi(check->items[1].value);
378
- if (marker_size <= 0)
379
- marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
380
- }
374
+ git_check_attr(&the_index, path, check);
375
+ ll_driver_name = check->items[0].value;
376
+ if (check->items[1].value) {
377
+ marker_size = atoi(check->items[1].value);
378
+ if (marker_size <= 0)
379
+ marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
380
}
381
driver = find_ll_merge_driver(ll_driver_name);
382
@@ -398,7 +397,8 @@ int ll_merge_marker_size(const char *path)
397
398
if (!check)
399
check = attr_check_initl("conflict-marker-size", NULL);
401
- if (!git_check_attr(&the_index, path, check) && check->items[0].value) {
400
+ git_check_attr(&the_index, path, check);
401
+ if (check->items[0].value) {
402
marker_size = atoi(check->items[0].value);
403
if (marker_size <= 0)
404
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
userdiff.c
+1
-2
@@ -278,8 +278,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path)
278
check = attr_check_initl("diff", NULL);
279
if (!path)
280
return NULL;
281
- if (git_check_attr(&the_index, path, check))
282
- return NULL;
281
+ git_check_attr(&the_index, path, check);
282
283
if (ATTR_TRUE(check->items[0].value))
284
return &driver_true;
ws.c
+20
-24
@@ -74,35 +74,31 @@ unsigned parse_whitespace_rule(const char *string)
74
unsigned whitespace_rule(const char *pathname)
75
{
76
static struct attr_check *attr_whitespace_rule;
77
+ const char *value;
78
79
if (!attr_whitespace_rule)
80
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
81
81
- if (!git_check_attr(&the_index, pathname, attr_whitespace_rule)) {
82
- const char *value;
83
-
84
- value = attr_whitespace_rule->items[0].value;
85
- if (ATTR_TRUE(value)) {
86
- /* true (whitespace) */
87
- unsigned all_rule = ws_tab_width(whitespace_rule_cfg);
88
- int i;
89
- for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
90
- if (!whitespace_rule_names[i].loosens_error &&
91
- !whitespace_rule_names[i].exclude_default)
92
- all_rule |= whitespace_rule_names[i].rule_bits;
93
- return all_rule;
94
- } else if (ATTR_FALSE(value)) {
95
- /* false (-whitespace) */
96
- return ws_tab_width(whitespace_rule_cfg);
97
- } else if (ATTR_UNSET(value)) {
98
- /* reset to default (!whitespace) */
99
- return whitespace_rule_cfg;
100
- } else {
101
- /* string */
102
- return parse_whitespace_rule(value);
103
- }
104
- } else {
82
+ git_check_attr(&the_index, pathname, attr_whitespace_rule);
83
+ value = attr_whitespace_rule->items[0].value;
84
+ if (ATTR_TRUE(value)) {
85
+ /* true (whitespace) */
86
+ unsigned all_rule = ws_tab_width(whitespace_rule_cfg);
87
+ int i;
88
+ for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
89
+ if (!whitespace_rule_names[i].loosens_error &&
90
+ !whitespace_rule_names[i].exclude_default)
91
+ all_rule |= whitespace_rule_names[i].rule_bits;
92
+ return all_rule;
93
+ } else if (ATTR_FALSE(value)) {
94
+ /* false (-whitespace) */
95
+ return ws_tab_width(whitespace_rule_cfg);
96
+ } else if (ATTR_UNSET(value)) {
97
+ /* reset to default (!whitespace) */
98
return whitespace_rule_cfg;
99
+ } else {
100
+ /* string */
101
+ return parse_whitespace_rule(value);
102
}
103
}
104