Skip to content

Commit

Permalink
Merge branch 'zk/push-use-bitmaps' into jch
Browse files Browse the repository at this point in the history
"git push" sometimes perform poorly when reachability bitmaps are
used, even in a repository where other operations are helped by
bitmaps.  The push.useBitmaps configuration variable is introduced
to allow disabling use of reachability bitmaps only for "git push".

* zk/push-use-bitmaps:
  send-pack.c: add config push.useBitmaps
  • Loading branch information
gitster committed Jun 22, 2022
2 parents dc9c370 + 82f67ee commit 8130449
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Documentation/config/push.txt
Expand Up @@ -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 set to "false", disable use of bitmaps for "git push" even if
`pack.useBitmaps` is "true", without preventing other git operations
from using bitmaps. Default is true.
6 changes: 6 additions & 0 deletions send-pack.c
Expand Up @@ -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->disable_bitmaps)
strvec_push(&po.args, "--no-use-bitmap-index");
po.in = -1;
po.out = args->stateless_rpc ? -1 : fd;
po.git_cmd = 1;
Expand Down Expand Up @@ -487,6 +489,7 @@ int send_pack(struct send_pack_args *args,
struct async demux;
const char *push_cert_nonce = NULL;
struct packet_reader reader;
int use_bitmaps;

if (!remote_refs) {
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
Expand All @@ -498,6 +501,9 @@ int send_pack(struct send_pack_args *args,
if (push_negotiate)
get_commons_through_negotiation(args->url, remote_refs, &commons);

if (!git_config_get_bool("push.usebitmaps", &use_bitmaps))
args->disable_bitmaps = !use_bitmaps;

git_config_get_bool("transfer.advertisesid", &advertise_sid);

/* Does the other end support the reporting? */
Expand Down
3 changes: 2 additions & 1 deletion send-pack.h
Expand Up @@ -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,
disable_bitmaps:1;
const struct string_list *push_options;
};

Expand Down
22 changes: 22 additions & 0 deletions t/t5516-fetch-push.sh
Expand Up @@ -1865,4 +1865,26 @@ test_expect_success LIBCURL '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 &&
test_unconfig push.useBitmaps &&
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 <default &&
test_config push.useBitmaps true &&
GIT_TRACE2_EVENT="$PWD/true" \
git push testrepo main:test2 &&
test_subcommand git pack-objects --all-progress-implied --revs --stdout \
--thin --delta-base-offset -q <true &&
test_config push.useBitmaps false &&
GIT_TRACE2_EVENT="$PWD/false" \
git push testrepo main:test3 &&
test_subcommand git pack-objects --all-progress-implied --revs --stdout \
--thin --delta-base-offset -q --no-use-bitmap-index <false
'

test_done

0 comments on commit 8130449

Please sign in to comment.