# git diagnose with invalid CLI argument does not report error

5 messages from 2023-10-25 to 2023-10-26. Participants: Sheik, Bagas Sanjaya, Eric Sunshine, Emily Shaffer.
Thread: https://gitlist.dev/t/60430

## Sheik, 2023-10-25 20:49

Subject: git diagnose with invalid CLI argument does not report error
Message-ID: <849b6ee2-99f3-4aaa-835f-44d3e13befc3@gmail.com>
URL: https://gitlist.dev/e/849b6ee2-99f3-4aaa-835f-44d3e13befc3%40gmail.com

```
Hi Maintainers,


Running git diagnose with an invalid CLI argument in a valid Git 
directory does not report error. Expected behaviour would be that it 
reports an error.

#Example shell commands which should have reported an error but 
continues to succeed

cd $ToAGitDirectory

git diagnose mod

git diagnose mode

git diagnose mode=all


Thanks

Sheik


[System Info]
git version:
git version 2.42.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.5.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1 
(2023-10-07) x86_64
compiler info: gnuc: 13.2
libc info: glibc: 2.37
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]


```

## Bagas Sanjaya, 2023-10-26 11:10

Subject: Re: git diagnose with invalid CLI argument does not report error
Message-ID: <ZTpJFUdE2U6pbV--@debian.me>
URL: https://gitlist.dev/e/ZTpJFUdE2U6pbV--%40debian.me
In-Reply-To: <849b6ee2-99f3-4aaa-835f-44d3e13befc3@gmail.com>

```
On Thu, Oct 26, 2023 at 07:49:58AM +1100, Sheik wrote:
> Hi Maintainers,
> 
> 
> Running git diagnose with an invalid CLI argument in a valid Git directory
> does not report error. Expected behaviour would be that it reports an error.
> 
> #Example shell commands which should have reported an error but continues to
> succeed
> 
> cd $ToAGitDirectory
> 
> git diagnose mod
> 
> git diagnose mode
> 
> git diagnose mode=all
> 

I can reproduce this only when the invalid parameter is a normal word:

ˋˋˋ
$ git diagnose huh
ˋˋˋ

But the command errors out on invalid flag:

ˋˋˋ
$ git diagnose -m
ˋˋˋ

Cc:'ing people who recently worked on builtin/diagnose.c for help.

Thanks.

-- 
An old man doll... just what I always wanted! - Clara

```

## Eric Sunshine, 2023-10-26 22:11

Subject: Re: git diagnose with invalid CLI argument does not report error
Message-ID: <CAPig+cSsB-2xxF7uQRU2h219+0-9++M_woLX3vNwiq1Uj1SiQQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcSsB-2xxF7uQRU2h219%2B0-9%2B%2BM_woLX3vNwiq1Uj1SiQQ%40mail.gmail.com
In-Reply-To: <ZTpJFUdE2U6pbV--@debian.me>

```
On Thu, Oct 26, 2023 at 7:10 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> On Thu, Oct 26, 2023 at 07:49:58AM +1100, Sheik wrote:
> > Hi Maintainers,
> >
> > Running git diagnose with an invalid CLI argument in a valid Git directory
> > does not report error. Expected behaviour would be that it reports an error.
> >
> > #Example shell commands which should have reported an error but continues to
> > succeed
> >
> > cd $ToAGitDirectory
> > git diagnose mod
> > git diagnose mode
> > git diagnose mode=all
>
> I can reproduce this only when the invalid parameter is a normal word:
> ˋˋˋ
> $ git diagnose huh
> ˋˋˋ
> But the command errors out on invalid flag:
> ˋˋˋ
> $ git diagnose -m
> ˋˋˋ
> Cc:'ing people who recently worked on builtin/diagnose.c for help.

A patch by Emily to fix this has been submitted[v4].

[v4]: https://lore.kernel.org/git/20231026182231.3369370-3-nasamuffin@google.com/

```

## Emily Shaffer, 2023-10-26 22:41

Subject: Re: git diagnose with invalid CLI argument does not report error
Message-ID: <CAJoAoZ=a30QsMXHz+47haZ=QGkY8-QYccSuY_94mi9h9RMiBFA@mail.gmail.com>
URL: https://gitlist.dev/e/CAJoAoZ%3Da30QsMXHz%2B47haZ%3DQGkY8-QYccSuY_94mi9h9RMiBFA%40mail.gmail.com
In-Reply-To: <CAPig+cSsB-2xxF7uQRU2h219+0-9++M_woLX3vNwiq1Uj1SiQQ@mail.gmail.com>

```
To be clear, that patch was for git-bugreport and doesn't cover
git-diagnose. I assume the fix ends up being pretty similar though.

On Thu, Oct 26, 2023 at 3:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Thu, Oct 26, 2023 at 7:10 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> > On Thu, Oct 26, 2023 at 07:49:58AM +1100, Sheik wrote:
> > > Hi Maintainers,
> > >
> > > Running git diagnose with an invalid CLI argument in a valid Git directory
> > > does not report error. Expected behaviour would be that it reports an error.
> > >
> > > #Example shell commands which should have reported an error but continues to
> > > succeed
> > >
> > > cd $ToAGitDirectory
> > > git diagnose mod
> > > git diagnose mode
> > > git diagnose mode=all
> >
> > I can reproduce this only when the invalid parameter is a normal word:
> > ˋˋˋ
> > $ git diagnose huh
> > ˋˋˋ
> > But the command errors out on invalid flag:
> > ˋˋˋ
> > $ git diagnose -m
> > ˋˋˋ
> > Cc:'ing people who recently worked on builtin/diagnose.c for help.
>
> A patch by Emily to fix this has been submitted[v4].
>
> [v4]: https://lore.kernel.org/git/20231026182231.3369370-3-nasamuffin@google.com/
>

```

## Eric Sunshine, 2023-10-26 22:43

Subject: Re: git diagnose with invalid CLI argument does not report error
Message-ID: <CAPig+cRU5bU-QkX3au_+DvM8KiKHLNeB1u+PB2LXgz6gu-4qzw@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRU5bU-QkX3au_%2BDvM8KiKHLNeB1u%2BPB2LXgz6gu-4qzw%40mail.gmail.com
In-Reply-To: <CAJoAoZ=a30QsMXHz+47haZ=QGkY8-QYccSuY_94mi9h9RMiBFA@mail.gmail.com>

```
On Thu, Oct 26, 2023 at 6:41 PM Emily Shaffer <nasamuffin@google.com> wrote:
> On Thu, Oct 26, 2023 at 3:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > On Thu, Oct 26, 2023 at 7:10 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> > > On Thu, Oct 26, 2023 at 07:49:58AM +1100, Sheik wrote:
> > > > Running git diagnose with an invalid CLI argument in a valid Git directory
> > > > does not report error. Expected behaviour would be that it reports an error.
> > >
> > > I can reproduce this only when the invalid parameter is a normal word:
> > > Cc:'ing people who recently worked on builtin/diagnose.c for help.
> >
> > A patch by Emily to fix this has been submitted[v4].
>
> To be clear, that patch was for git-bugreport and doesn't cover
> git-diagnose. I assume the fix ends up being pretty similar though.

My bad.

```
