From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] http-push: trim trailing newline from remote symref
Date: Tue, 13 Jan 2015 15:41:40 -0500 [thread overview]
Message-ID: <20150113204140.GA16238@peff.net> (raw)
In-Reply-To: <20150113022857.GA4087@peff.net>
On Mon, Jan 12, 2015 at 09:28:58PM -0500, Jeff King wrote:
> When we fetch a symbolic ref file from the remote, we get
> the whole string "ref: refs/heads/master\n", recognize it by
> skipping past the "ref: ", and store the rest. We should
> chomp the trailing newline.
>
> This bug was introduced in ae021d8 (use skip_prefix to avoid
> magic numbers, 2014-06-18), which did not notice that the
> length computation fed to xmemdupz was quietly tweaked by 1
> to account for this.
>
> We can solve it by explicitly trimming the newline, which is
> more obvious. Note that we use strbuf_rtrim here, which will
> actually cut off any trailing whitespace, not just a single
> newline. This is a good thing, though, as it makes our
> parsing more liberal (and spaces are not valid in refnames
> anyway).
While looking into Kyle's earlier response, I found that there is a
semi-duplicate of this function for the http-walker side:
http_fetch_ref. It already uses strbuf_rtrim, so I feel doubly good
about moving to its use here.
Almost certainly this duplicated functionality could be factored out. I
have very little interest in spending time cleaning up the http-push
code, though.
-Peff
prev parent reply other threads:[~2015-01-13 20:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 2:28 [PATCH] http-push: trim trailing newline from remote symref Jeff King
2015-01-13 16:26 ` Kyle J. McKay
2015-01-13 19:58 ` Jeff King
2015-01-14 0:21 ` Kyle J. McKay
2015-01-16 1:19 ` Junio C Hamano
2015-01-13 20:41 ` Jeff King [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150113204140.GA16238@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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 NNTP newsgroup(s).