зеркало из https://github.com/microsoft/git.git
Merge branch 'tb/void-check-attr'
Code clean-up. * tb/void-check-attr: Make git_check_attr() a void function
This commit is contained in:
Коммит
10de0f802d
|
@ -110,7 +110,8 @@ static const struct attr_check *get_archive_attrs(struct index_state *istate,
|
||||||
static struct attr_check *check;
|
static struct attr_check *check;
|
||||||
if (!check)
|
if (!check)
|
||||||
check = attr_check_initl("export-ignore", "export-subst", NULL);
|
check = attr_check_initl("export-ignore", "export-subst", NULL);
|
||||||
return git_check_attr(istate, path, check) ? NULL : check;
|
git_check_attr(istate, path, check);
|
||||||
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_attr_export_ignore(const struct attr_check *check)
|
static int check_attr_export_ignore(const struct attr_check *check)
|
||||||
|
|
8
attr.c
8
attr.c
|
@ -1143,9 +1143,9 @@ static void collect_some_attrs(const struct index_state *istate,
|
||||||
fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
|
fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_check_attr(const struct index_state *istate,
|
void git_check_attr(const struct index_state *istate,
|
||||||
const char *path,
|
const char *path,
|
||||||
struct attr_check *check)
|
struct attr_check *check)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1158,8 +1158,6 @@ int git_check_attr(const struct index_state *istate,
|
||||||
value = ATTR__UNSET;
|
value = ATTR__UNSET;
|
||||||
check->items[i].value = value;
|
check->items[i].value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void git_all_attrs(const struct index_state *istate,
|
void git_all_attrs(const struct index_state *istate,
|
||||||
|
|
4
attr.h
4
attr.h
|
@ -63,8 +63,8 @@ void attr_check_free(struct attr_check *check);
|
||||||
*/
|
*/
|
||||||
const char *git_attr_name(const struct git_attr *);
|
const char *git_attr_name(const struct git_attr *);
|
||||||
|
|
||||||
int git_check_attr(const struct index_state *istate,
|
void git_check_attr(const struct index_state *istate,
|
||||||
const char *path, struct attr_check *check);
|
const char *path, struct attr_check *check);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve all attributes that apply to the specified path.
|
* Retrieve all attributes that apply to the specified path.
|
||||||
|
|
|
@ -65,8 +65,7 @@ static void check_attr(const char *prefix,
|
||||||
if (collect_all) {
|
if (collect_all) {
|
||||||
git_all_attrs(&the_index, full_path, check);
|
git_all_attrs(&the_index, full_path, check);
|
||||||
} else {
|
} else {
|
||||||
if (git_check_attr(&the_index, full_path, check))
|
git_check_attr(&the_index, full_path, check);
|
||||||
die("git_check_attr died");
|
|
||||||
}
|
}
|
||||||
output_attr(check, file);
|
output_attr(check, file);
|
||||||
|
|
||||||
|
|
|
@ -970,8 +970,7 @@ static int no_try_delta(const char *path)
|
||||||
|
|
||||||
if (!check)
|
if (!check)
|
||||||
check = attr_check_initl("delta", NULL);
|
check = attr_check_initl("delta", NULL);
|
||||||
if (git_check_attr(&the_index, path, check))
|
git_check_attr(&the_index, path, check);
|
||||||
return 0;
|
|
||||||
if (ATTR_FALSE(check->items[0].value))
|
if (ATTR_FALSE(check->items[0].value))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
42
convert.c
42
convert.c
|
@ -1297,6 +1297,7 @@ static void convert_attrs(const struct index_state *istate,
|
||||||
struct conv_attrs *ca, const char *path)
|
struct conv_attrs *ca, const char *path)
|
||||||
{
|
{
|
||||||
static struct attr_check *check;
|
static struct attr_check *check;
|
||||||
|
struct attr_check_item *ccheck = NULL;
|
||||||
|
|
||||||
if (!check) {
|
if (!check) {
|
||||||
check = attr_check_initl("crlf", "ident", "filter",
|
check = attr_check_initl("crlf", "ident", "filter",
|
||||||
|
@ -1306,30 +1307,25 @@ static void convert_attrs(const struct index_state *istate,
|
||||||
git_config(read_convert_config, NULL);
|
git_config(read_convert_config, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!git_check_attr(istate, path, check)) {
|
git_check_attr(istate, path, check);
|
||||||
struct attr_check_item *ccheck = check->items;
|
ccheck = check->items;
|
||||||
ca->crlf_action = git_path_check_crlf(ccheck + 4);
|
ca->crlf_action = git_path_check_crlf(ccheck + 4);
|
||||||
if (ca->crlf_action == CRLF_UNDEFINED)
|
if (ca->crlf_action == CRLF_UNDEFINED)
|
||||||
ca->crlf_action = git_path_check_crlf(ccheck + 0);
|
ca->crlf_action = git_path_check_crlf(ccheck + 0);
|
||||||
ca->ident = git_path_check_ident(ccheck + 1);
|
ca->ident = git_path_check_ident(ccheck + 1);
|
||||||
ca->drv = git_path_check_convert(ccheck + 2);
|
ca->drv = git_path_check_convert(ccheck + 2);
|
||||||
if (ca->crlf_action != CRLF_BINARY) {
|
if (ca->crlf_action != CRLF_BINARY) {
|
||||||
enum eol eol_attr = git_path_check_eol(ccheck + 3);
|
enum eol eol_attr = git_path_check_eol(ccheck + 3);
|
||||||
if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_LF)
|
if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_LF)
|
||||||
ca->crlf_action = CRLF_AUTO_INPUT;
|
ca->crlf_action = CRLF_AUTO_INPUT;
|
||||||
else if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_CRLF)
|
else if (ca->crlf_action == CRLF_AUTO && eol_attr == EOL_CRLF)
|
||||||
ca->crlf_action = CRLF_AUTO_CRLF;
|
ca->crlf_action = CRLF_AUTO_CRLF;
|
||||||
else if (eol_attr == EOL_LF)
|
else if (eol_attr == EOL_LF)
|
||||||
ca->crlf_action = CRLF_TEXT_INPUT;
|
ca->crlf_action = CRLF_TEXT_INPUT;
|
||||||
else if (eol_attr == EOL_CRLF)
|
else if (eol_attr == EOL_CRLF)
|
||||||
ca->crlf_action = CRLF_TEXT_CRLF;
|
ca->crlf_action = CRLF_TEXT_CRLF;
|
||||||
}
|
|
||||||
ca->working_tree_encoding = git_path_check_encoding(ccheck + 5);
|
|
||||||
} else {
|
|
||||||
ca->drv = NULL;
|
|
||||||
ca->crlf_action = CRLF_UNDEFINED;
|
|
||||||
ca->ident = 0;
|
|
||||||
}
|
}
|
||||||
|
ca->working_tree_encoding = git_path_check_encoding(ccheck + 5);
|
||||||
|
|
||||||
/* Save attr and make a decision for action */
|
/* Save attr and make a decision for action */
|
||||||
ca->attr_action = ca->crlf_action;
|
ca->attr_action = ca->crlf_action;
|
||||||
|
|
16
ll-merge.c
16
ll-merge.c
|
@ -371,13 +371,12 @@ int ll_merge(mmbuffer_t *result_buf,
|
||||||
if (!check)
|
if (!check)
|
||||||
check = attr_check_initl("merge", "conflict-marker-size", NULL);
|
check = attr_check_initl("merge", "conflict-marker-size", NULL);
|
||||||
|
|
||||||
if (!git_check_attr(&the_index, path, check)) {
|
git_check_attr(&the_index, path, check);
|
||||||
ll_driver_name = check->items[0].value;
|
ll_driver_name = check->items[0].value;
|
||||||
if (check->items[1].value) {
|
if (check->items[1].value) {
|
||||||
marker_size = atoi(check->items[1].value);
|
marker_size = atoi(check->items[1].value);
|
||||||
if (marker_size <= 0)
|
if (marker_size <= 0)
|
||||||
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
|
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
driver = find_ll_merge_driver(ll_driver_name);
|
driver = find_ll_merge_driver(ll_driver_name);
|
||||||
|
|
||||||
|
@ -398,7 +397,8 @@ int ll_merge_marker_size(const char *path)
|
||||||
|
|
||||||
if (!check)
|
if (!check)
|
||||||
check = attr_check_initl("conflict-marker-size", NULL);
|
check = attr_check_initl("conflict-marker-size", NULL);
|
||||||
if (!git_check_attr(&the_index, path, check) && check->items[0].value) {
|
git_check_attr(&the_index, path, check);
|
||||||
|
if (check->items[0].value) {
|
||||||
marker_size = atoi(check->items[0].value);
|
marker_size = atoi(check->items[0].value);
|
||||||
if (marker_size <= 0)
|
if (marker_size <= 0)
|
||||||
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
|
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
|
||||||
|
|
|
@ -278,8 +278,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path)
|
||||||
check = attr_check_initl("diff", NULL);
|
check = attr_check_initl("diff", NULL);
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (git_check_attr(&the_index, path, check))
|
git_check_attr(&the_index, path, check);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (ATTR_TRUE(check->items[0].value))
|
if (ATTR_TRUE(check->items[0].value))
|
||||||
return &driver_true;
|
return &driver_true;
|
||||||
|
|
44
ws.c
44
ws.c
|
@ -74,35 +74,31 @@ unsigned parse_whitespace_rule(const char *string)
|
||||||
unsigned whitespace_rule(const char *pathname)
|
unsigned whitespace_rule(const char *pathname)
|
||||||
{
|
{
|
||||||
static struct attr_check *attr_whitespace_rule;
|
static struct attr_check *attr_whitespace_rule;
|
||||||
|
const char *value;
|
||||||
|
|
||||||
if (!attr_whitespace_rule)
|
if (!attr_whitespace_rule)
|
||||||
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
|
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
|
||||||
|
|
||||||
if (!git_check_attr(&the_index, pathname, attr_whitespace_rule)) {
|
git_check_attr(&the_index, pathname, attr_whitespace_rule);
|
||||||
const char *value;
|
value = attr_whitespace_rule->items[0].value;
|
||||||
|
if (ATTR_TRUE(value)) {
|
||||||
value = attr_whitespace_rule->items[0].value;
|
/* true (whitespace) */
|
||||||
if (ATTR_TRUE(value)) {
|
unsigned all_rule = ws_tab_width(whitespace_rule_cfg);
|
||||||
/* true (whitespace) */
|
int i;
|
||||||
unsigned all_rule = ws_tab_width(whitespace_rule_cfg);
|
for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
|
||||||
int i;
|
if (!whitespace_rule_names[i].loosens_error &&
|
||||||
for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
|
!whitespace_rule_names[i].exclude_default)
|
||||||
if (!whitespace_rule_names[i].loosens_error &&
|
all_rule |= whitespace_rule_names[i].rule_bits;
|
||||||
!whitespace_rule_names[i].exclude_default)
|
return all_rule;
|
||||||
all_rule |= whitespace_rule_names[i].rule_bits;
|
} else if (ATTR_FALSE(value)) {
|
||||||
return all_rule;
|
/* false (-whitespace) */
|
||||||
} else if (ATTR_FALSE(value)) {
|
return ws_tab_width(whitespace_rule_cfg);
|
||||||
/* false (-whitespace) */
|
} else if (ATTR_UNSET(value)) {
|
||||||
return ws_tab_width(whitespace_rule_cfg);
|
/* reset to default (!whitespace) */
|
||||||
} else if (ATTR_UNSET(value)) {
|
|
||||||
/* reset to default (!whitespace) */
|
|
||||||
return whitespace_rule_cfg;
|
|
||||||
} else {
|
|
||||||
/* string */
|
|
||||||
return parse_whitespace_rule(value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return whitespace_rule_cfg;
|
return whitespace_rule_cfg;
|
||||||
|
} else {
|
||||||
|
/* string */
|
||||||
|
return parse_whitespace_rule(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче