diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-08-17 23:09:54 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-17 23:09:54 +0300 |
commit | f8ca71870a4265320fbbecb4f676d0ad1d4bf176 (patch) | |
tree | 0afc6ceb4ac171967442abbb84ddb3ed8ec6f6c0 /fetch-pack.c | |
parent | 63749b2dea5d1501ff85bab7b8a7f64911d21dea (diff) | |
parent | 8a6d0525b74fe07bde0436e4cbf87b23adf7df0a (diff) |
Merge branch 'ab/fsck-transfer-updates'
The test performed at the receiving end of "git push" to prevent
bad objects from entering repository can be customized via
receive.fsck.* configuration variables; we now have gained a
counterpart to do the same on the "git fetch" side, with
fetch.fsck.* configuration variables.
* ab/fsck-transfer-updates:
fsck: test and document unknown fsck.<msg-id> values
fsck: add stress tests for fsck.skipList
fsck: test & document {fetch,receive}.fsck.* config fallback
fetch: implement fetch.fsck.*
transfer.fsckObjects tests: untangle confusing setup
config doc: elaborate on fetch.fsckObjects security
config doc: elaborate on what transfer.fsckObjects does
config doc: unify the description of fsck.* and receive.fsck.*
config doc: don't describe *.fetchObjects twice
receive.fsck.<msg-id> tests: remove dead code
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index f80a7acdf3..88a078e9be 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -21,6 +21,7 @@ #include "object-store.h" #include "connected.h" #include "fetch-negotiator.h" +#include "fsck.h" static int transfer_unpack_limit = -1; static int fetch_unpack_limit = -1; @@ -36,6 +37,7 @@ static int server_supports_filtering; static struct lock_file shallow_lock; static const char *alternate_shallow_file; static char *negotiation_algorithm; +static struct strbuf fsck_msg_types = STRBUF_INIT; /* Remember to update object flag allocation in object.h */ #define COMPLETE (1U << 0) @@ -867,7 +869,8 @@ static int get_pack(struct fetch_pack_args *args, */ argv_array_push(&cmd.args, "--fsck-objects"); else - argv_array_push(&cmd.args, "--strict"); + argv_array_pushf(&cmd.args, "--strict%s", + fsck_msg_types.buf); } cmd.in = demux.out; @@ -1401,6 +1404,31 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, return ref; } +static int fetch_pack_config_cb(const char *var, const char *value, void *cb) +{ + if (strcmp(var, "fetch.fsck.skiplist") == 0) { + const char *path; + + if (git_config_pathname(&path, var, value)) + return 1; + strbuf_addf(&fsck_msg_types, "%cskiplist=%s", + fsck_msg_types.len ? ',' : '=', path); + free((char *)path); + return 0; + } + + if (skip_prefix(var, "fetch.fsck.", &var)) { + if (is_valid_msg_type(var, value)) + strbuf_addf(&fsck_msg_types, "%c%s=%s", + fsck_msg_types.len ? ',' : '=', var, value); + else + warning("Skipping unknown msg id '%s'", var); + return 0; + } + + return git_default_config(var, value, cb); +} + static void fetch_pack_config(void) { git_config_get_int("fetch.unpacklimit", &fetch_unpack_limit); @@ -1411,7 +1439,7 @@ static void fetch_pack_config(void) git_config_get_string("fetch.negotiationalgorithm", &negotiation_algorithm); - git_config(git_default_config, NULL); + git_config(fetch_pack_config_cb, NULL); } static void fetch_pack_setup(void) |