Subject: Re: [bug] Multiline value should error if the next line is section

From: SZEDER Gábor <[email-masked]>
Date: Mon, 7 May 2018 01:25:14 +0200

> On Sun, 6 May 2018 22:03:10 +0200
> Martin Ågren <[email-masked]> wrote:
> > On 6 May 2018 at 21:03, Shulhan <[email-masked]> wrote:
> > > [alias]
> > >         tree = --no-pager log --graph \
> > >                 -n 20 \
> > > [user]
> > >         name = Shulhan
> > >
> > > (2) Run `git config -f git.config -l`
> > >
> > > The command print the following output,
> > >
> > > alias.tree=--no-pager log --graph -n 20 [user]
> > > alias.name=Shulhan  
> > 
> > Small mistake, big consequences. :-)
> > 
> > This behavior looks correct to me, though. It seems very hard to me to
> > second-guess what the user meant. For example, what if that third line
> > contained a "="? Like:
> > 
> > [alias]
> >         huh = !dd \
> >               bs=1024 ...
> > 
> > Should Git guess that the backslash on the second line was a mistake?
> > Or maybe not, because alias.bs = "1024 ..." would be a useless alias?
> 
> The context of multiline next value that I reported before was
> about section, not variable.
> 
> > 
> > I think such guessing would be theoretically possible, but especially
> > if Git guesses wrong, that could be very frustrating to fight against.
> > 
> 
> I'm not familiar with git config parser, obviously :), but checking
> the start of next multiline value that start with '[' maybe not
> impossible. Git should not guessed, but report error at the
> offending line: either user forgot to enclosed the variable with
> double quote or they missplace the backslash.

But it's not an error; as far as the config file syntax is concerned,
it's perfectly valid, even if it's not what you intended.  Reporting it
as error would be just guessing.