git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Joey Hess <id@joeyh.name>
Cc: git@vger.kernel.org
Subject: Re: git cat-file --batch surprising carriage return behavior
Date: Tue, 8 Oct 2019 16:00:50 -0400
Message-ID: <20191008200050.GA26453@sigill.intra.peff.net> (raw)
In-Reply-To: <20191008192257.GA16870@kitenet.net>

On Tue, Oct 08, 2019 at 03:22:57PM -0400, Joey Hess wrote:

> I'm surprised to find that git cat-file --batch, on a Linux system,
> strips the \r from an input like "HEAD:foo\r\n"
> 
> It's obvious, of course, that it will remove the newline, and so this
> interface cannot be used to query about a filename that, for some
> horrible reason[1], contains a newline. But very surprising that it
> cannot be used for filename that contains a carriage return, at least
> on a non-Windows system.

This is likely due to b42ca3dd0f (cat-file: read batch stream with
strbuf_getline(), 2015-10-28), and the matching c8aa9fdf5d (strbuf: make
strbuf_getline_crlf() global, 2015-10-28).

I agree it's a bit surprising (though OTOH, I imagine the old behavior
surprised some people in the opposite direction).

> The docs for cat-file --batch say the list of objects is separated by
> linefeeds. I don't know if updating the docs is the best fix.
> (I'd be happy to use a -z if it had one.)

Yeah, I agree that a -z option is the best path forward. For non-z
input, I'm tempted to say we could unquote entries that start with a
double-quote (the match to how we handle filenames in non-z diff
output). That would mean breaking compatibility for refnames that start
with a quote, though. If we just add a new "-z", that's less disruptive
_and_ easier to use.

I suspect it's not entirely sufficient for clean input, though. You're
not feeding filenames but rather full "object names". I wouldn't be
surprised if we mis-parse "$rev:$path" when $path has "@{}" or similar
in it.

So what you may actually want is some more robust input format that lets
you specify the filename as an independent NUL-terminated entity.

-Peff

  reply	other threads:[~2019-10-08 20:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 19:22 Joey Hess
2019-10-08 20:00 ` Jeff King [this message]
2019-10-09 15:28   ` Joey Hess
2019-10-11  6:21     ` Jeff King

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=20191008200050.GA26453@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=id@joeyh.name \
    /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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git