transfer.fsckobjects: unify fetch/receive.fsckobjects

This single variable can be used to set instead of setting fsckobjects variable for fetch & receive independently. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 4, 2011 at 12:37 UTC dab76d3aa682a340e886df84da33326368c38633
3 files changed +35 -7
Documentation/config.txt
+9 -2
@@ -824,7 +824,8 @@ fetch.fsckObjects::
824 If it is set to true, git-fetch-pack will check all fetched
825 objects. It will abort in the case of a malformed object or a
826 broken link. The result of an abort are only dangling objects.
827 - Defaults to false.
827 + Defaults to false. If not set, the value of `transfer.fsckObjects`
828 + is used instead.
829
830 fetch.unpackLimit::
831 If the number of objects fetched over the git native
@@ -1427,7 +1428,8 @@ receive.fsckObjects::
1428 If it is set to true, git-receive-pack will check all received
1429 objects. It will abort in the case of a malformed object or a
1430 broken link. The result of an abort are only dangling objects.
1430 - Defaults to false.
1431 + Defaults to false. If not set, the value of `transfer.fsckObjects`
1432 + is used instead.
1433
1434 receive.unpackLimit::
1435 If the number of objects received in a push is below this
@@ -1616,6 +1618,11 @@ tar.umask::
1618 archiving user's umask will be used instead. See umask(2) and
1619 linkgit:git-archive[1].
1620
1621 +transfer.fsckObjects::
1622 + When `fetch.fsckObjects` or `receive.fsckObjects` are
1623 + not set, the value of this variable is used instead.
1624 + Defaults to false.
1625 +
1626 transfer.unpackLimit::
1627 When `fetch.unpackLimit` or `receive.unpackLimit` are
1628 not set, the value of this variable is used instead.
builtin/fetch-pack.c
+12 -2
@@ -14,7 +14,8 @@ static int transfer_unpack_limit = -1;
14 static int fetch_unpack_limit = -1;
15 static int unpack_limit = 100;
16 static int prefer_ofs_delta = 1;
17 -static int fetch_fsck_objects;
17 +static int fetch_fsck_objects = -1;
18 +static int transfer_fsck_objects = -1;
19 static struct fetch_pack_args args = {
20 /* .uploadpack = */ "git-upload-pack",
21 };
@@ -664,7 +665,11 @@ static int get_pack(int xd[2], char **pack_lockfile)
665 }
666 if (*hdr_arg)
667 *av++ = hdr_arg;
667 - if (fetch_fsck_objects)
668 + if (fetch_fsck_objects >= 0
669 + ? fetch_fsck_objects
670 + : transfer_fsck_objects >= 0
671 + ? transfer_fsck_objects
672 + : 0)
673 *av++ = "--strict";
674 *av++ = NULL;
675
@@ -784,6 +789,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
789 return 0;
790 }
791
792 + if (!strcmp(var, "transfer.fsckobjects")) {
793 + transfer_fsck_objects = git_config_bool(var, value);
794 + return 0;
795 + }
796 +
797 return git_default_config(var, value, cb);
798 }
799
builtin/receive-pack.c
+14 -3
@@ -23,7 +23,8 @@ static int deny_deletes;
23 static int deny_non_fast_forwards;
24 static enum deny_action deny_current_branch = DENY_UNCONFIGURED;
25 static enum deny_action deny_delete_current = DENY_UNCONFIGURED;
26 -static int receive_fsck_objects;
26 +static int receive_fsck_objects = -1;
27 +static int transfer_fsck_objects = -1;
28 static int receive_unpack_limit = -1;
29 static int transfer_unpack_limit = -1;
30 static int unpack_limit = 100;
@@ -77,6 +78,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
78 return 0;
79 }
80
81 + if (strcmp(var, "transfer.fsckobjects") == 0) {
82 + transfer_fsck_objects = git_config_bool(var, value);
83 + return 0;
84 + }
85 +
86 if (!strcmp(var, "receive.denycurrentbranch")) {
87 deny_current_branch = parse_deny_action(var, value);
88 return 0;
@@ -586,6 +592,11 @@ static const char *unpack(void)
592 struct pack_header hdr;
593 const char *hdr_err;
594 char hdr_arg[38];
595 + int fsck_objects = (receive_fsck_objects >= 0
596 + ? receive_fsck_objects
597 + : transfer_fsck_objects >= 0
598 + ? transfer_fsck_objects
599 + : 0);
600
601 hdr_err = parse_pack_header(&hdr);
602 if (hdr_err)
@@ -598,7 +609,7 @@ static const char *unpack(void)
609 int code, i = 0;
610 const char *unpacker[4];
611 unpacker[i++] = "unpack-objects";
601 - if (receive_fsck_objects)
612 + if (fsck_objects)
613 unpacker[i++] = "--strict";
614 unpacker[i++] = hdr_arg;
615 unpacker[i++] = NULL;
@@ -618,7 +629,7 @@ static const char *unpack(void)
629
630 keeper[i++] = "index-pack";
631 keeper[i++] = "--stdin";
621 - if (receive_fsck_objects)
632 + if (fsck_objects)
633 keeper[i++] = "--strict";
634 keeper[i++] = "--fix-thin";
635 keeper[i++] = hdr_arg;