From: David Turner <dturner@twopensource.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH/RFC 5/6] fetch: pass refspec to http server
Date: Tue, 19 Apr 2016 17:25:46 -0400 [thread overview]
Message-ID: <1461101146.5540.120.camel@twopensource.com> (raw)
In-Reply-To: <CAPig+cSxkuWB5qqVY3-m9ESmmHMKwXM+qtbRsZ1j1osjp2i3HQ@mail.gmail.com>
On Sat, 2016-04-16 at 22:33 -0400, Eric Sunshine wrote:
> On Fri, Apr 15, 2016 at 3:19 PM, David Turner <
> dturner@twopensource.com> wrote:
> > When fetching over http, send the requested refspec to the server.
> > The server will then only send refs matching that refspec. It is
> > permitted for old servers to ignore that parameter, and the client
> > will automatically handle this.
> >
> > When the server has many refs, and the client only wants a few,
> > this
> > can save bandwidth and reduce fetch latency.
> >
> > Signed-off-by: David Turner <dturner@twopensource.com>
> > ---
> > diff --git a/builtin/fetch.c b/builtin/fetch.c
> > @@ -302,9 +302,27 @@ static struct ref *get_ref_map(struct
> > transport *transport,
> > - remote_refs = transport_get_remote_refs(transport, NULL,
> > 0);
> > + qualified_refspecs = xcalloc(refspec_count,
> > sizeof(*qualified_refspecs));
> > + for (i = 0; i < refspec_count; i++) {
> > + if (starts_with(refspecs[i].src, "refs/")) {
> > + qualified_refspecs[i].src =
> > xstrdup(refspecs[i].src);
> > + } else {
> > + struct strbuf buf = STRBUF_INIT;
> > + strbuf_addf(&buf, "refs/heads/%s",
> > refspecs[i].src);
> > + qualified_refspecs[i].src =
> > strbuf_detach(&buf, NULL);
>
> Alternately, replace these three lines with:
>
> qualified_refspecs[i].src = xstrfmt("refs/heads/%s",
> refspecs[i].src);
>
> and drop the braces.
Yep, good point.
> > + }
> > + }
> > +
> > + remote_refs = transport_get_remote_refs(transport,
> > qualified_refspecs,
> > + refspec_count);
> > +
> > + for (i = 0; i < refspec_count; i++) {
> > + free(qualified_refspecs[i].src);
> > + }
> > + free(qualified_refspecs);
> > diff --git a/t/t5552-http-fetch-branch.sh b/t/t5552-http-fetch
> > -branch.sh
> > @@ -0,0 +1,42 @@
> > +test_expect_success 'make some more commits' '
> > + (
> > + cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
> > + test_commit 2 &&
> > + git checkout -b another_branch &&
> > + test_commit 3
>
> Broken &&-chain.
Thanks.
> > + git checkout -b a_third_branch &&
> > + test_commit 4
> > + )
> > +'
> > +
> > +test_expect_success 'fetch with refspec only fetches requested
> > branch' '
> > + test_when_finished "rm trace" &&
> > + (
> > + cd clone &&
> > + GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch
> > origin another_branch &&
> > + ! grep "refs/heads/master" ../trace
> > + )
> > +'
>
> This could be done without the subshell, perhaps?
>
> GIT_TRACE_PACKET=blah git -C clone fetch ...
Will fix these, thanks.
next prev parent reply other threads:[~2016-04-19 21:25 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 19:19 [PATCH/RFC 0/6] fetch with refspec David Turner
2016-04-15 19:19 ` [PATCH/RFC 1/6] http-backend: use argv_array functions David Turner
2016-04-18 18:34 ` Junio C Hamano
2016-04-19 19:11 ` David Turner
2016-04-15 19:19 ` [PATCH/RFC 2/6] remote-curl.c: fix variable shadowing David Turner
2016-04-18 18:35 ` Junio C Hamano
2016-04-19 19:14 ` David Turner
2016-04-15 19:19 ` [PATCH/RFC 3/6] http-backend: handle refspec argument David Turner
2016-04-17 1:51 ` Eric Sunshine
2016-04-19 18:57 ` David Turner
2016-04-15 19:19 ` [PATCH/RFC 4/6] transport: add refspec list parameters to functions David Turner
2016-04-18 18:45 ` Junio C Hamano
2016-04-19 7:14 ` Jeff King
2016-04-19 18:04 ` Stefan Beller
2016-04-19 20:55 ` Junio C Hamano
2016-04-19 21:40 ` David Turner
2016-04-19 23:22 ` Jeff King
2016-04-19 23:43 ` David Turner
2016-04-20 1:17 ` Jeff King
2016-04-20 20:46 ` David Turner
2016-04-20 20:57 ` Jeff King
2016-04-25 16:44 ` David Turner
2016-04-25 22:10 ` Stefan Beller
2016-04-27 3:59 ` Stefan Beller
2016-04-27 4:11 ` Jeff King
2016-04-27 15:07 ` Junio C Hamano
2016-04-29 23:05 ` David Turner
2016-04-29 23:12 ` Stefan Beller
2016-04-19 19:31 ` David Turner
2016-04-15 19:19 ` [PATCH/RFC 5/6] fetch: pass refspec to http server David Turner
2016-04-17 2:33 ` Eric Sunshine
2016-04-19 21:25 ` David Turner [this message]
2016-04-15 19:19 ` [PATCH/RFC 6/6] clone: send refspec for single-branch clones David Turner
2016-04-17 2:36 ` Eric Sunshine
2016-04-19 21:24 ` David Turner
2016-04-15 19:30 ` [PATCH/RFC 0/6] fetch with refspec Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461101146.5540.120.camel@twopensource.com \
--to=dturner@twopensource.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).