diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-27 18:01:57 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-01 13:46:52 -0800 |
commit | 2aef63d31c338a764099e925d35fe2a9c71348a8 (patch) | |
tree | 61d17684220a639cbf92e11b6370db7f0f6d933c /ll-merge.c | |
parent | 7f8641112de8724a565a47b0f0b2a9b826b6baa9 (diff) | |
download | git-2aef63d31c338a764099e925d35fe2a9c71348a8.tar.gz |
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 <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'll-merge.c')
-rw-r--r-- | ll-merge.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/ll-merge.c b/ll-merge.c index 198f07aca1..ac0d4a5d78 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; } |