From 2aef63d31c338a764099e925d35fe2a9c71348a8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 27 Jan 2017 18:01:57 -0800 Subject: attr: convert git_check_attrs() callers to use the new API The remaining callers are all simple "I have N attributes I am interested in. I'll ask about them with various paths one by one". After this step, no caller to git_check_attrs() remains. After removing it, we can extend "struct attr_check" struct with data that can be used in optimizing the query for the specific N attributes it contains. Signed-off-by: Junio C Hamano Signed-off-by: Stefan Beller Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- ll-merge.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'll-merge.c') diff --git a/ll-merge.c b/ll-merge.c index 198f07aca..ac0d4a5d7 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -336,15 +336,6 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr return &ll_merge_drv[LL_TEXT_MERGE]; } -static int git_path_check_merge(const char *path, struct attr_check_item check[2]) -{ - if (!check[0].attr) { - check[0].attr = git_attr("merge"); - check[1].attr = git_attr("conflict-marker-size"); - } - return git_check_attrs(path, 2, check); -} - static void normalize_file(mmfile_t *mm, const char *path) { struct strbuf strbuf = STRBUF_INIT; @@ -362,7 +353,7 @@ int ll_merge(mmbuffer_t *result_buf, mmfile_t *theirs, const char *their_label, const struct ll_merge_options *opts) { - static struct attr_check_item check[2]; + 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; @@ -376,10 +367,14 @@ int ll_merge(mmbuffer_t *result_buf, normalize_file(ours, path); normalize_file(theirs, path); } - if (!git_path_check_merge(path, check)) { - ll_driver_name = check[0].value; - if (check[1].value) { - marker_size = atoi(check[1].value); + + if (!check) + check = attr_check_initl("merge", "conflict-marker-size", NULL); + + if (!git_check_attr(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; } @@ -398,13 +393,13 @@ int ll_merge(mmbuffer_t *result_buf, int ll_merge_marker_size(const char *path) { - static struct attr_check_item check; + static struct attr_check *check; int marker_size = DEFAULT_CONFLICT_MARKER_SIZE; - if (!check.attr) - check.attr = git_attr("conflict-marker-size"); - if (!git_check_attrs(path, 1, &check) && check.value) { - marker_size = atoi(check.value); + if (!check) + check = attr_check_initl("conflict-marker-size", NULL); + if (!git_check_attr(path, check) && check->items[0].value) { + marker_size = atoi(check->items[0].value); if (marker_size <= 0) marker_size = DEFAULT_CONFLICT_MARKER_SIZE; } -- cgit v1.2.1