diff --git a/Documentation/config/push.txt b/Documentation/config/push.txt index e32801e6c91d81..3f3ff66fe7c9b9 100644 --- a/Documentation/config/push.txt +++ b/Documentation/config/push.txt @@ -137,3 +137,8 @@ push.negotiate:: server attempt to find commits in common. If "false", Git will rely solely on the server's ref advertisement to find commits in common. + +push.useBitmaps:: + If this config and `pack.useBitmaps` are both `true`, then Git will + use reachability bitmaps during `git push`, if available (disabled + by default). diff --git a/send-pack.c b/send-pack.c index bc0fcdbb000769..4b2b4449b82ac5 100644 --- a/send-pack.c +++ b/send-pack.c @@ -84,6 +84,8 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised, strvec_push(&po.args, "--progress"); if (is_repository_shallow(the_repository)) strvec_push(&po.args, "--shallow"); + if (!args->use_bitmaps) + strvec_push(&po.args, "--no-use-bitmap-index"); po.in = -1; po.out = args->stateless_rpc ? -1 : fd; po.git_cmd = 1; @@ -482,6 +484,7 @@ int send_pack(struct send_pack_args *args, int use_push_options = 0; int push_options_supported = 0; int object_format_supported = 0; + int use_bitmaps = 0; unsigned cmds_sent = 0; int ret; struct async demux; @@ -497,6 +500,8 @@ int send_pack(struct send_pack_args *args, git_config_get_bool("push.negotiate", &push_negotiate); if (push_negotiate) get_commons_through_negotiation(args->url, remote_refs, &commons); + if (!git_config_get_bool("push.usebitmaps", &use_bitmaps)) + args->use_bitmaps = use_bitmaps; git_config_get_bool("transfer.advertisesid", &advertise_sid); diff --git a/send-pack.h b/send-pack.h index e148fcd960994b..f7af1b0353e9b5 100644 --- a/send-pack.h +++ b/send-pack.h @@ -26,7 +26,8 @@ struct send_pack_args { /* One of the SEND_PACK_PUSH_CERT_* constants. */ push_cert:2, stateless_rpc:1, - atomic:1; + atomic:1, + use_bitmaps:1; const struct string_list *push_options; }; diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index dedca106a7adee..0d416d1474f4d2 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1865,4 +1865,25 @@ test_expect_success 'push warns or fails when using username:password' ' test_line_count = 1 warnings ' +test_expect_success 'push with config push.useBitmaps' ' + mk_test testrepo heads/main && + git checkout main && + GIT_TRACE2_EVENT="$PWD/default" \ + git push testrepo main:test && + test_subcommand git pack-objects --all-progress-implied --revs --stdout \ + --thin --delta-base-offset -q --no-use-bitmap-index