Example #1
0
File: ws.c Project: foggg7777/git
unsigned whitespace_rule(const char *pathname)
{
	static struct attr_check *attr_whitespace_rule;
	const char *value;

	if (!attr_whitespace_rule)
		attr_whitespace_rule = attr_check_initl("whitespace", NULL);

	git_check_attr(&the_index, pathname, attr_whitespace_rule);
	value = attr_whitespace_rule->items[0].value;
	if (ATTR_TRUE(value)) {
		/* true (whitespace) */
		unsigned all_rule = ws_tab_width(whitespace_rule_cfg);
		int i;
		for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
			if (!whitespace_rule_names[i].loosens_error &&
			    !whitespace_rule_names[i].exclude_default)
				all_rule |= whitespace_rule_names[i].rule_bits;
		return all_rule;
	} else if (ATTR_FALSE(value)) {
		/* false (-whitespace) */
		return ws_tab_width(whitespace_rule_cfg);
	} else if (ATTR_UNSET(value)) {
		/* reset to default (!whitespace) */
		return whitespace_rule_cfg;
	} else {
		/* string */
		return parse_whitespace_rule(value);
	}
}
Example #2
0
static const struct attr_check *get_archive_attrs(struct index_state *istate,
						  const char *path)
{
	static struct attr_check *check;
	if (!check)
		check = attr_check_initl("export-ignore", "export-subst", NULL);
	git_check_attr(istate, path, check);
	return check;
}
Example #3
0
int ll_merge_marker_size(const char *path)
{
	static struct attr_check *check;
	int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;

	if (!check)
		check = attr_check_initl("conflict-marker-size", NULL);
	if (!git_check_attr(&the_index, path, check) && check->items[0].value) {
		marker_size = atoi(check->items[0].value);
		if (marker_size <= 0)
			marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
	}
	return marker_size;
}
Example #4
0
int ll_merge(mmbuffer_t *result_buf,
	     const char *path,
	     mmfile_t *ancestor, const char *ancestor_label,
	     mmfile_t *ours, const char *our_label,
	     mmfile_t *theirs, const char *their_label,
	     const struct ll_merge_options *opts)
{
	static struct attr_check *check;
	static const struct ll_merge_options default_opts;
	const char *ll_driver_name = NULL;
	int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
	const struct ll_merge_driver *driver;

	if (!opts)
		opts = &default_opts;

	if (opts->renormalize) {
		normalize_file(ancestor, path);
		normalize_file(ours, path);
		normalize_file(theirs, path);
	}

	if (!check)
		check = attr_check_initl("merge", "conflict-marker-size", NULL);

	if (!git_check_attr(&the_index, path, check)) {
		ll_driver_name = check->items[0].value;
		if (check->items[1].value) {
			marker_size = atoi(check->items[1].value);
			if (marker_size <= 0)
				marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
		}
	}
	driver = find_ll_merge_driver(ll_driver_name);

	if (opts->virtual_ancestor) {
		if (driver->recursive)
			driver = find_ll_merge_driver(driver->recursive);
		marker_size += 2;
	}
	return driver->fn(driver, result_buf, path, ancestor, ancestor_label,
			  ours, our_label, theirs, their_label,
			  opts, marker_size);
}
Example #5
0
struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
					      const char *path)
{
	static struct attr_check *check;

	if (!check)
		check = attr_check_initl("diff", NULL);
	if (!path)
		return NULL;
	git_check_attr(istate, path, check);

	if (ATTR_TRUE(check->items[0].value))
		return &driver_true;
	if (ATTR_FALSE(check->items[0].value))
		return &driver_false;
	if (ATTR_UNSET(check->items[0].value))
		return NULL;
	return userdiff_find_by_name(check->items[0].value);
}