git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: What's cooking in git.git (Jan 2016, #02; Mon, 11)
Date: Wed, 13 Jan 2016 18:22:56 -0500	[thread overview]
Message-ID: <20160113232255.GA17937@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqtwmhkrj2.fsf@gitster.mtv.corp.google.com>

On Wed, Jan 13, 2016 at 03:07:13PM -0800, Junio C Hamano wrote:

> > And then after a quiet period we can drop the "_crlf()" and have
> > strbuf_getline() back.
> 
> Actually, I think a patch that
> 
>  - renames strbuf_getline() to strbuf_getdelim(); and
>  - renames strbuf_getline_crlf() to strbuf_getline() 
> 
> on top of the series we already have is sufficient to bring the
> endgame state to us.  The new strbuf_getline() has a different
> function signature from the traditional one, so any topic in flight
> that is unaware of this series can easily be caught, and we can do
> this without a quiet period.

Ah, right, I forgot about the changed function signature.

> A more interesting question is if strbuf_getdelim() should take an
> arbitrary byte as its third parameter.  As I said elsewhere, the
> only reason why it is not a "do we use LF or do we use NUL?"
> boolean is because I wrote these codepaths anticipating that there
> might be a value other than NUL and LF that could be useful when I
> introduced line_termination long time ago, but no useful caller that
> uses other useful value has emerged, so I think the interface was
> too broad and too general for its own good.
> 
> It becomes very tempting not to do strbuf_getdelim() at all, but
> instead rewrite the current calls to strbuf_getline() to call one of
> two functions, i.e. strbuf_getline_lf() and strbuf_getline_nul(),
> when we rename strbuf_getline_crlf() to strbuf_getline().

I think you'll end up with some of the callers being a bit uglier. I.e.,
where we say:

  strbuf_getline(&buf, in, delim);

and "delim" is set elsewhere. These will become:

  if (delim == '\n') /* or maybe even "if (nul_terminate)" */
	strbuf_getline_lf(&buf, in);
  else
	strbuf_getline_nul(&buf, in);

which is a bit less nice.  But I guess these cases already need to
become uglier if we want them to handle CRLF. Unless we want to wrap the
idiom as:

  int strbuf_get_record(struct strbuf *buf,
			FILE *in,
			enum { STRBUF_RECORD_LINE,
			       STRBUF_RECORD_NUL
			     } delim);

and then "-z" option parsers use STRBUF_RECORD_NUL instead of setting a
char to '\0'.

> By going that route, those who want to help CRLF situation further
> can then concentrate on output from "git grep strbuf_getline_lf()",
> identify the ones that can be safely turned into strbuf_getline(),
> and do the conversion.

I'm not sure that is any easier than just grepping for strbuf_delim()
that takes '\n').

-Peff

  reply	other threads:[~2016-01-13 23:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 23:45 What's cooking in git.git (Jan 2016, #02; Mon, 11) Junio C Hamano
2016-01-12  0:06 ` Mike Hommey
2016-01-12  3:04   ` Junio C Hamano
2016-01-12  4:34 ` Edmundo Carmona Antoranz
2016-01-12  8:39 ` Johannes Schindelin
2016-01-12 18:47   ` Junio C Hamano
2016-01-12 21:49     ` Jeff King
2016-01-13 23:07       ` Junio C Hamano
2016-01-13 23:22         ` Jeff King [this message]
2016-01-13 23:44           ` Junio C Hamano
2016-01-13 23:54             ` Junio C Hamano
2016-01-14 10:21               ` Jeff King
2016-01-13  2:56 ` David A. Greene
2016-01-18 13:35 ` Michael J Gruber
2016-01-18 17:06   ` Jeff King
2016-01-18 21:39     ` Eric Wong
2016-01-19  7:07       ` Michael J Gruber
2016-01-25  9:56 ` Duy Nguyen
2016-01-25 22:03   ` Junio C Hamano

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=20160113232255.GA17937@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --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).