Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

git: add receive.advertiseAlternates patch

This should let us drop the excessively long ".have" lists
you get when pushing to heavily-forked repos.
  • Loading branch information...
commit e049b724735358ea47194fd79a7c10ff6a433ea1 1 parent 1fa8f89
Jeff King peff authored
5 packages/git/formula.rb
@@ -5,7 +5,7 @@ class Git < DebianFormula
5 5
6 6 section 'vcs'
7 7 name 'git'
8   - version '1:1.7.5.4-1+github8'
  8 + version '1:1.7.5.4-1+github9'
9 9 description <<-DESC
10 10 The Git DVCS with custom patches and bugfixes for GitHub.
11 11 DESC
@@ -42,6 +42,9 @@ def patches
42 42 # eliminate duplicate .have refs
43 43 'patches/remove-duplicate-dot-have-lines.patch',
44 44
  45 + # allow turning off .have lines entirely
  46 + 'patches/receive-pack-advertise-alternates.patch',
  47 +
45 48 # speed up git-fetch with large number of refs
46 49 'patches/git-fetch-performance.patch',
47 50
65 packages/git/patches/receive-pack-advertise-alternates.patch
... ... @@ -0,0 +1,65 @@
  1 +From 88c91fcd2c276623d79447b215bca02641d64dfa Mon Sep 17 00:00:00 2001
  2 +From: Jeff King <peff@peff.net>
  3 +Date: Wed, 4 Jan 2012 09:28:23 -0500
  4 +Subject: [PATCH] receive-pack: respect receive.advertiseAlternates config
  5 +
  6 +Usually receive-pack advertises ref tips from alternates
  7 +repositories so that clients can sometimes avoid sending
  8 +objects that are already upstream.
  9 +
  10 +However, if you have a very large alternates network, then
  11 +the number of ".have" refs can get cumbersome, and you spend
  12 +more time advertising refs that the client doesn't care
  13 +about than you are saving in the optimization.
  14 +
  15 +This patch adds a config variable to drop .have lines
  16 +entirely.
  17 +
  18 +An alternative approach would be to restrict the .have lines
  19 +to a smaller portion of the namespace that is known to be
  20 +"interesting" to most clients. This patch is much simpler;
  21 +if the loss of the .have optimization turns out to be too
  22 +much, we can try something more complex.
  23 +
  24 +Signed-off-by: Jeff King <peff@peff.net>
  25 +---
  26 + builtin/receive-pack.c | 9 ++++++++-
  27 + 1 files changed, 8 insertions(+), 1 deletions(-)
  28 +
  29 +diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
  30 +index e1ba4dc..69e8e8a 100644
  31 +--- a/builtin/receive-pack.c
  32 ++++ b/builtin/receive-pack.c
  33 +@@ -35,6 +35,7 @@ static int auto_update_server_info;
  34 + static int auto_gc = 1;
  35 + static const char *head_name;
  36 + static int sent_capabilities;
  37 ++static int advertise_alternates = 1;
  38 +
  39 + static enum deny_action parse_deny_action(const char *var, const char *value)
  40 + {
  41 +@@ -103,6 +104,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
  42 + return 0;
  43 + }
  44 +
  45 ++ if (strcmp(var, "receive.advertisealternates") == 0) {
  46 ++ advertise_alternates = git_config_bool(var, value);
  47 ++ return 0;
  48 ++ }
  49 ++
  50 + return git_default_config(var, value, cb);
  51 + }
  52 +
  53 +@@ -790,7 +796,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
  54 + unpack_limit = receive_unpack_limit;
  55 +
  56 + if (advertise_refs || !stateless_rpc) {
  57 +- add_alternate_refs();
  58 ++ if (advertise_alternates)
  59 ++ add_alternate_refs();
  60 + write_head_info();
  61 + clear_extra_refs();
  62 +
  63 +--
  64 +1.7.8.2.6.g2e4b88
  65 +

0 comments on commit e049b72

Please sign in to comment.
Something went wrong with that request. Please try again.