userdiff: add and use struct external_diff

Wrap the string specifying the external diff command in a new struct to
simplify adding attributes, which the next patch will do.

Make sure external_diff() still returns NULL if neither the environment
variable GIT_EXTERNAL_DIFF nor the configuration option diff.external is
set, to continue allowing its use in a boolean context.

Use a designated initializer for the default builtin userdiff driver to
adjust to the type change of the second struct member.  Spelling out
only the non-zero members improves readability as a nice side-effect.

No functional change intended.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2024-06-09 09:39:08 +02:00
committed by Junio C Hamano
parent 33be6cf51a
commit 54443bbfc3
3 changed files with 24 additions and 18 deletions

View File

@ -11,9 +11,13 @@ struct userdiff_funcname {
int cflags;
};
struct external_diff {
char *cmd;
};
struct userdiff_driver {
const char *name;
char *external;
struct external_diff external;
char *algorithm;
int binary;
struct userdiff_funcname funcname;