]> git.ipfire.org Git - thirdparty/git.git/commitdiff
xdiff users: use designated initializers for out_line
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 12 Apr 2021 17:15:28 +0000 (19:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 May 2021 03:47:31 +0000 (12:47 +0900)
Amend the code added in 611e42a5980 (xdiff: provide a separate emit
callback for hunks, 2018-11-02) to be more readable by using
designated initializers.

This changes "priv" in rerere.c to be initialized to NULL as we did in
merge-tree.c. That's not needed as we'll only use it if the callback
is defined, but being consistent here is better and less verbose.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge-tree.c
builtin/rerere.c

index de8520778d2ecdaa01dc23b513e24d187ef89d08..5dc94d6f8804d600a37e75079b59b1960db32ef7 100644 (file)
@@ -107,15 +107,12 @@ static void show_diff(struct merge_list *entry)
        mmfile_t src, dst;
        xpparam_t xpp;
        xdemitconf_t xecfg;
-       xdemitcb_t ecb;
+       xdemitcb_t ecb = { .out_line = show_outf };
 
        memset(&xpp, 0, sizeof(xpp));
        xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
-       ecb.out_hunk = NULL;
-       ecb.out_line = show_outf;
-       ecb.priv = NULL;
 
        src.ptr = origin(entry, &size);
        if (!src.ptr)
index fd3be17b976c7d2f413b4e760236c2274f1e7639..83d7a778e374be053f861145690c161b21d9801c 100644 (file)
@@ -28,7 +28,7 @@ static int diff_two(const char *file1, const char *label1,
 {
        xpparam_t xpp;
        xdemitconf_t xecfg;
-       xdemitcb_t ecb;
+       xdemitcb_t ecb = { .out_line = outf };
        mmfile_t minus, plus;
        int ret;
 
@@ -41,8 +41,6 @@ static int diff_two(const char *file1, const char *label1,
        xpp.flags = 0;
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
-       ecb.out_hunk = NULL;
-       ecb.out_line = outf;
        ret = xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
 
        free(minus.ptr);