# [bug] Multiline value should error if the next line is section

5 messages from 2018-05-06 to 2018-05-06. Participants: Shulhan, Martin Ågren, brian m. carlson, SZEDER Gábor.
Thread: https://gitlist.dev/t/48425

## Shulhan, 2018-05-06 19:03

Subject: [bug] Multiline value should error if the next line is section
Message-ID: <20180507020348.31b473b4@kilabit.info>
URL: https://gitlist.dev/e/20180507020348.31b473b4%40kilabit.info

```
## Environment

OS: Arch Linux
Git version: git@next d54016d9e

## Reproduction Steps

(1) Create the following `git.config`,

ˋˋˋ
[alias]
        tree = --no-pager log --graph \
                --date=format:'%Y-%m-%d' \
                --pretty=format:'%C(auto,dim)%ad %<(7,trunc) %an %Creset%m %h %s %Cgreen%d%Creset' \
                --exclude="*/production" \
                --exclude="*/dev-*" \
                -n 20 \
[user]
        name = Shulhan
        email = ms@kilabit.info
ˋˋˋ

(2) Run `git config -f git.config -l`


## Expected Result

Error message,

  fatal: bad config line 9 at git.config


## Actual Result

The command print the following output,

ˋˋˋ
alias.tree=--no-pager log --graph
--date=format:'%Y-%m-%d'
--pretty=format:'%C(auto,dim)%ad %<(7,trunc) %an %Creset%m %h %s %Cgreen%d%Creset' --exclude=*/production                 --exclude=*/dev-*                 -n 20 [user]
alias.name=Shulhan
alias.email=ms@kilabit.info
ˋˋˋ

```

## Martin Ågren, 2018-05-06 20:03

Subject: Re: [bug] Multiline value should error if the next line is section
Message-ID: <CAN0heSooYuGkxP9u0Uuwu_TCEOd_pj20L05=bwwHynPOapej6g@mail.gmail.com>
URL: https://gitlist.dev/e/CAN0heSooYuGkxP9u0Uuwu_TCEOd_pj20L05%3DbwwHynPOapej6g%40mail.gmail.com
In-Reply-To: <20180507020348.31b473b4@kilabit.info>

```
Hi Shulhan

Thank you for your report. I'm abbreviating a bit:

On 6 May 2018 at 21:03, Shulhan <ms@kilabit.info> 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?

I think such guessing would be theoretically possible, but especially if
Git guesses wrong, that could be very frustrating to fight against.

Martin

```

## brian m. carlson, 2018-05-06 21:09

Subject: Re: [bug] Multiline value should error if the next line is section
Message-ID: <20180506210943.GA953644@genre.crustytoothpaste.net>
URL: https://gitlist.dev/e/20180506210943.GA953644%40genre.crustytoothpaste.net
In-Reply-To: <CAN0heSooYuGkxP9u0Uuwu_TCEOd_pj20L05=bwwHynPOapej6g@mail.gmail.com>

```
On Sun, May 06, 2018 at 10:03:10PM +0200, Martin Ågren wrote:
> 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?
> 
> I think such guessing would be theoretically possible, but especially if
> Git guesses wrong, that could be very frustrating to fight against.

I agree that trying to guess what the user wanted here is likely
impossible.

Furthermore, Git intentionally ignores unknown options.  For example, I
have advice and diff options set in my .gitconfig that would not be
valid on the Git shipped with a base CentOS 6 (which, unfortunately, I
sometimes have to use).  It's very convenient for users working across a
variety of systems that unknown options are simply ignored, even if that
means sometimes mistakes are not caught.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

```

## Shulhan, 2018-05-06 23:03

Subject: Re: [bug] Multiline value should error if the next line is section
Message-ID: <20180507060322.66b121bd@kilabit.info>
URL: https://gitlist.dev/e/20180507060322.66b121bd%40kilabit.info
In-Reply-To: <CAN0heSooYuGkxP9u0Uuwu_TCEOd_pj20L05=bwwHynPOapej6g@mail.gmail.com>

```
On Sun, 6 May 2018 22:03:10 +0200
Martin Ågren <martin.agren@gmail.com> wrote:

> Hi Shulhan
> 
> Thank you for your report. I'm abbreviating a bit:
> 
> On 6 May 2018 at 21:03, Shulhan <ms@kilabit.info> 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.

```

## SZEDER Gábor, 2018-05-06 23:25

Subject: Re: [bug] Multiline value should error if the next line is section
Message-ID: <20180506232514.3065-1-szeder.dev@gmail.com>
URL: https://gitlist.dev/e/20180506232514.3065-1-szeder.dev%40gmail.com
In-Reply-To: <20180507060322.66b121bd@kilabit.info>

```

> On Sun, 6 May 2018 22:03:10 +0200
> Martin Ågren <martin.agren@gmail.com> wrote:
> > On 6 May 2018 at 21:03, Shulhan <ms@kilabit.info> 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. 


```
