public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Moritz Neeb <lists@moritzneeb•de>
Cc: "git\@vger.kernel.org" <git@vger•kernel.org>
Subject: Re: Replacing strbuf_getline_lf() by strbuf_getline() in wt-status.c
Date: Sun, 31 Jan 2016 08:59:55 -0800	[thread overview]
Message-ID: <xmqqd1shy99w.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <56ACC916.8020008@moritzneeb.de> (Moritz Neeb's message of "Sat, 30 Jan 2016 15:30:46 +0100")

Moritz Neeb <lists@moritzneeb•de> writes:

> Currently I am working on replacing strbuf_getline_lf() by
> strbuf_getline() in places where the input is trimmed immediately after
> reading, cf. $gmane/284104, "Notes on the remaining strbuf_getline_lf()
> callers", 2nd point.
>
> One instance I found was in wt-status.c. In read_rebase_todolist() the
> lines are read, checked for a comment_line_char and then trimmed. I
> wonder why the input is not trimmed before checking for this character?
> Is it safe to replace strbuf_getline_lf() by strbuf_getline() anyway?
>
> The only case I can imagine that could lead to unexpected behaviour then
> would be when someone sets the comment_line_char to CR. How likely is that?
>
> Why is the trim after checking for the comment char anyway? Should
> something like "   # foobar" not be considered as comment?

That is debatable, I would think, as "git commit" and others do not
generally accept a line that does not begin with a comment char as a
comment.

I however think we made an exception for the rebase-i's insn file
due to a mistake we made long time ago that allowed such line,
caused people to build a workflow around the assumption that it is
OK to prefix a comment line with whitespaces.

  Cf. the last paragraph of 1db168ee (rebase-i: loosen over-eager
      check_bad_cmd check, 2015-10-01).

  Cf. http://thread.gmane.org/gmane.comp.version-control.git/278841

So we probably want to be consistent with that in this codepath.

      parent reply	other threads:[~2016-01-31 17:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-30 14:30 Replacing strbuf_getline_lf() by strbuf_getline() in wt-status.c Moritz Neeb
2016-01-30 22:49 ` Moritz Neeb
2016-01-31 16:59 ` Junio C Hamano [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=xmqqd1shy99w.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=lists@moritzneeb$(echo .)de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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