git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [bug] Multiline value should error if the next line is section
@ 2018-05-06 19:03 Shulhan
  2018-05-06 20:03 ` Martin Ågren
  0 siblings, 1 reply; 5+ messages in thread
From: Shulhan @ 2018-05-06 19:03 UTC (permalink / raw)
  To: git

## 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
```

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [bug] Multiline value should error if the next line is section
  2018-05-06 19:03 [bug] Multiline value should error if the next line is section Shulhan
@ 2018-05-06 20:03 ` Martin Ågren
  2018-05-06 21:09   ` brian m. carlson
  2018-05-06 23:03   ` Shulhan
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Ågren @ 2018-05-06 20:03 UTC (permalink / raw)
  To: Shulhan; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [bug] Multiline value should error if the next line is section
  2018-05-06 20:03 ` Martin Ågren
@ 2018-05-06 21:09   ` brian m. carlson
  2018-05-06 23:03   ` Shulhan
  1 sibling, 0 replies; 5+ messages in thread
From: brian m. carlson @ 2018-05-06 21:09 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Shulhan, Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [bug] Multiline value should error if the next line is section
  2018-05-06 20:03 ` Martin Ågren
  2018-05-06 21:09   ` brian m. carlson
@ 2018-05-06 23:03   ` Shulhan
  2018-05-06 23:25     ` SZEDER Gábor
  1 sibling, 1 reply; 5+ messages in thread
From: Shulhan @ 2018-05-06 23:03 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Git Mailing List

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [bug] Multiline value should error if the next line is section
  2018-05-06 23:03   ` Shulhan
@ 2018-05-06 23:25     ` SZEDER Gábor
  0 siblings, 0 replies; 5+ messages in thread
From: SZEDER Gábor @ 2018-05-06 23:25 UTC (permalink / raw)
  To: Shulhan; +Cc: SZEDER Gábor, Martin Ågren, Git Mailing List


> 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. 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-06 23:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-06 19:03 [bug] Multiline value should error if the next line is section Shulhan
2018-05-06 20:03 ` Martin Ågren
2018-05-06 21:09   ` brian m. carlson
2018-05-06 23:03   ` Shulhan
2018-05-06 23:25     ` SZEDER Gábor

Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).