Skip to content

Commit 50eb7d3

Browse files
authored
Merge pull request libgit2#6184 from boretrk/noflexarray
diff_driver: split global_drivers array into separate elements
2 parents 4fead63 + 5388e0c commit 50eb7d3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/diff_driver.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ struct git_diff_driver_registry {
5151

5252
#define FORCE_DIFFABLE (GIT_DIFF_FORCE_TEXT | GIT_DIFF_FORCE_BINARY)
5353

54-
static git_diff_driver global_drivers[3] = {
55-
{ DIFF_DRIVER_AUTO, 0, 0, },
56-
{ DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 },
57-
{ DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 },
58-
};
54+
static git_diff_driver diff_driver_auto = { DIFF_DRIVER_AUTO, 0, 0 };
55+
static git_diff_driver diff_driver_binary = { DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 };
56+
static git_diff_driver diff_driver_text = { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 };
5957

6058
git_diff_driver_registry *git_diff_driver_registry_new(void)
6159
{
@@ -266,7 +264,7 @@ static int git_diff_driver_load(
266264
switch (git_config__get_bool_force(cfg, name.ptr, -1)) {
267265
case true:
268266
/* if diff.<driver>.binary is true, just return the binary driver */
269-
*out = &global_drivers[DIFF_DRIVER_BINARY];
267+
*out = &diff_driver_binary;
270268
goto done;
271269
case false:
272270
/* if diff.<driver>.binary is false, force binary checks off */
@@ -374,9 +372,9 @@ int git_diff_driver_lookup(
374372
else if (GIT_ATTR_IS_UNSPECIFIED(values[0]))
375373
/* just use the auto value */;
376374
else if (GIT_ATTR_IS_FALSE(values[0]))
377-
*out = &global_drivers[DIFF_DRIVER_BINARY];
375+
*out = &diff_driver_binary;
378376
else if (GIT_ATTR_IS_TRUE(values[0]))
379-
*out = &global_drivers[DIFF_DRIVER_TEXT];
377+
*out = &diff_driver_text;
380378

381379
/* otherwise look for driver information in config and build driver */
382380
else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) {
@@ -387,7 +385,7 @@ int git_diff_driver_lookup(
387385
}
388386

389387
if (!*out)
390-
*out = &global_drivers[DIFF_DRIVER_AUTO];
388+
*out = &diff_driver_auto;
391389

392390
return error;
393391
}

0 commit comments

Comments
 (0)