1323
return -1;
1324
}
1325
1326
+static const struct fsync_component_name {
1327
+ const char *name;
1328
+ enum fsync_component component_bits;
1329
+} fsync_component_names[] = {
1330
+ { "loose-object", FSYNC_COMPONENT_LOOSE_OBJECT },
1331
+ { "pack", FSYNC_COMPONENT_PACK },
1332
+ { "pack-metadata", FSYNC_COMPONENT_PACK_METADATA },
1333
+ { "commit-graph", FSYNC_COMPONENT_COMMIT_GRAPH },
1334
+};
1335
+
1336
+static enum fsync_component parse_fsync_components(const char *var, const char *string)
1337
+{
1338
+ enum fsync_component current = FSYNC_COMPONENTS_DEFAULT;
1339
+ enum fsync_component positive = 0, negative = 0;
1340
+
1341
+ while (string) {
1342
+ int i;
1343
+ size_t len;
1344
+ const char *ep;
1345
+ int negated = 0;
1346
+ int found = 0;
1347
+
1348
+ string = string + strspn(string, ", \t\n\r");
1349
+ ep = strchrnul(string, ',');
1350
+ len = ep - string;
1351
+ if (!strcmp(string, "none")) {
1352
+ current = FSYNC_COMPONENT_NONE;
1353
+ goto next_name;
1354
+ }
1355
+
1356
+ if (*string == '-') {
1357
+ negated = 1;
1358
+ string++;
1359
+ len--;
1360
+ if (!len)
1361
+ warning(_("invalid value for variable %s"), var);
1362
+ }
1363
+
1364
+ if (!len)
1365
+ break;
1366
+
1367
+ for (i = 0; i < ARRAY_SIZE(fsync_component_names); ++i) {
1368
+ const struct fsync_component_name *n = &fsync_component_names[i];
1369
+
1370
+ if (strncmp(n->name, string, len))
1371
+ continue;
1372
+
1373
+ found = 1;
1374
+ if (negated)
1375
+ negative |= n->component_bits;
1376
+ else
1377
+ positive |= n->component_bits;
1378
+ }
1379
+
1380
+ if (!found) {
1381
+ char *component = xstrndup(string, len);
1382
+ warning(_("ignoring unknown core.fsync component '%s'"), component);
1383
+ free(component);
1384
+ }
1385
+
1386
+next_name:
1387
+ string = ep;
1388
+ }
1389
+
1390
+ return (current & ~negative) | positive;
1391
+}
1392
+
1393
int git_parse_maybe_bool(const char *value)
1394
{
1395
int v = git_parse_maybe_bool_text(value);
1667
return 0;
1668
}
1669
1670
+ if (!strcmp(var, "core.fsync")) {
1671
+ if (!value)
1672
+ return config_error_nonbool(var);
1673
+ fsync_components = parse_fsync_components(var, value);
1674
+ return 0;
1675
+ }
1676
+
1677
if (!strcmp(var, "core.fsyncmethod")) {
1678
if (!value)
1679
return config_error_nonbool(var);
1687
}
1688
1689
if (!strcmp(var, "core.fsyncobjectfiles")) {
1690
+ if (fsync_object_files < 0)
1691
+ warning(_("core.fsyncobjectfiles is deprecated; use core.fsync instead"));
1692
fsync_object_files = git_config_bool(var, value);
1693
return 0;
1694
}