Skip to content

Commit dab76d3

Browse files
committed
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 <[email protected]>
1 parent 5e838ea commit dab76d3

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

Documentation/config.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ fetch.fsckObjects::
824824
If it is set to true, git-fetch-pack will check all fetched
825825
objects. It will abort in the case of a malformed object or a
826826
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.
828829

829830
fetch.unpackLimit::
830831
If the number of objects fetched over the git native
@@ -1427,7 +1428,8 @@ receive.fsckObjects::
14271428
If it is set to true, git-receive-pack will check all received
14281429
objects. It will abort in the case of a malformed object or a
14291430
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.
14311433

14321434
receive.unpackLimit::
14331435
If the number of objects received in a push is below this
@@ -1616,6 +1618,11 @@ tar.umask::
16161618
archiving user's umask will be used instead. See umask(2) and
16171619
linkgit:git-archive[1].
16181620

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+
16191626
transfer.unpackLimit::
16201627
When `fetch.unpackLimit` or `receive.unpackLimit` are
16211628
not set, the value of this variable is used instead.

builtin/fetch-pack.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ static int transfer_unpack_limit = -1;
1414
static int fetch_unpack_limit = -1;
1515
static int unpack_limit = 100;
1616
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;
1819
static struct fetch_pack_args args = {
1920
/* .uploadpack = */ "git-upload-pack",
2021
};
@@ -664,7 +665,11 @@ static int get_pack(int xd[2], char **pack_lockfile)
664665
}
665666
if (*hdr_arg)
666667
*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)
668673
*av++ = "--strict";
669674
*av++ = NULL;
670675

@@ -784,6 +789,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
784789
return 0;
785790
}
786791

792+
if (!strcmp(var, "transfer.fsckobjects")) {
793+
transfer_fsck_objects = git_config_bool(var, value);
794+
return 0;
795+
}
796+
787797
return git_default_config(var, value, cb);
788798
}
789799

builtin/receive-pack.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ static int deny_deletes;
2323
static int deny_non_fast_forwards;
2424
static enum deny_action deny_current_branch = DENY_UNCONFIGURED;
2525
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;
2728
static int receive_unpack_limit = -1;
2829
static int transfer_unpack_limit = -1;
2930
static int unpack_limit = 100;
@@ -77,6 +78,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
7778
return 0;
7879
}
7980

81+
if (strcmp(var, "transfer.fsckobjects") == 0) {
82+
transfer_fsck_objects = git_config_bool(var, value);
83+
return 0;
84+
}
85+
8086
if (!strcmp(var, "receive.denycurrentbranch")) {
8187
deny_current_branch = parse_deny_action(var, value);
8288
return 0;
@@ -586,6 +592,11 @@ static const char *unpack(void)
586592
struct pack_header hdr;
587593
const char *hdr_err;
588594
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);
589600

590601
hdr_err = parse_pack_header(&hdr);
591602
if (hdr_err)
@@ -598,7 +609,7 @@ static const char *unpack(void)
598609
int code, i = 0;
599610
const char *unpacker[4];
600611
unpacker[i++] = "unpack-objects";
601-
if (receive_fsck_objects)
612+
if (fsck_objects)
602613
unpacker[i++] = "--strict";
603614
unpacker[i++] = hdr_arg;
604615
unpacker[i++] = NULL;
@@ -618,7 +629,7 @@ static const char *unpack(void)
618629

619630
keeper[i++] = "index-pack";
620631
keeper[i++] = "--stdin";
621-
if (receive_fsck_objects)
632+
if (fsck_objects)
622633
keeper[i++] = "--strict";
623634
keeper[i++] = "--fix-thin";
624635
keeper[i++] = hdr_arg;

0 commit comments

Comments
 (0)