# git log alias with --all and --exclude

6 messages from 2024-09-04 to 2024-09-05. Participants: Rene Kita, Johannes Sixt, Jacob Keller, Junio C Hamano.
Thread: https://gitlist.dev/t/62056

## Rene Kita, 2024-09-04 09:06

Subject: git log alias with --all and --exclude
Message-ID: <20240904090614.GZ15670@t480>
URL: https://gitlist.dev/e/20240904090614.GZ15670%40t480

```
I have an alias
'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
and I would like to be able to sometimes exclude a branch, so call it
with:
$ git gr --exclude=pattern

This does not work, though. Also does not work without the alias and
typing the complete command by hand. Apparently the --exclude must be
put before the --all to take effect.

May I ask to change that behavior and allow to put the --exclude at the
end of the alias?

Rene

```

## Johannes Sixt, 2024-09-04 16:49

Subject: Re: git log alias with --all and --exclude
Message-ID: <0e0fb1c3-d4f7-413b-9985-d71cb1c300df@kdbg.org>
URL: https://gitlist.dev/e/0e0fb1c3-d4f7-413b-9985-d71cb1c300df%40kdbg.org
In-Reply-To: <20240904090614.GZ15670@t480>

```
Am 04.09.24 um 11:06 schrieb Rene Kita:
> I have an alias
> 'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
> and I would like to be able to sometimes exclude a branch, so call it
> with:
> $ git gr --exclude=pattern
> 
> This does not work, though. Also does not work without the alias and
> typing the complete command by hand. Apparently the --exclude must be
> put before the --all to take effect.

That is very much by design, so that you can express "branches except
the wip and preview branches and remotes except those from the remote
archive" with

--exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes

These collective branch options --branches, --remotes, and --all clear
the exclude patterns after having them applied. Therefore, in this example,
the first two --exclude do not affect --remotes.

-- Hannes


```

## Rene Kita, 2024-09-04 18:08

Subject: Re: git log alias with --all and --exclude
Message-ID: <20240904180826.GB15670@t480>
URL: https://gitlist.dev/e/20240904180826.GB15670%40t480
In-Reply-To: <0e0fb1c3-d4f7-413b-9985-d71cb1c300df@kdbg.org>

```
On Wed, Sep 04, 2024 at 06:49:12PM +0200, Johannes Sixt wrote:
> Am 04.09.24 um 11:06 schrieb Rene Kita:
> > I have an alias
> > 'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
> > and I would like to be able to sometimes exclude a branch, so call it
> > with:
> > $ git gr --exclude=pattern
> > 
> > This does not work, though. Also does not work without the alias and
> > typing the complete command by hand. Apparently the --exclude must be
> > put before the --all to take effect.
> 
> That is very much by design, so that you can express "branches except
> the wip and preview branches and remotes except those from the remote
> archive" with
> 
> --exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes
> 
> These collective branch options --branches, --remotes, and --all clear
> the exclude patterns after having them applied. Therefore, in this example,
> the first two --exclude do not affect --remotes.

OK, certainly not the answer I hoped for, but something I still
expected. Thanks for the explanation.

> -- Hannes
> 

```

## Jacob Keller, 2024-09-04 19:58

Subject: Re: git log alias with --all and --exclude
Message-ID: <CA+P7+xo9DnTitgVjHzpW1ODwRdFruDf+g+isg5pSHT8f27ASvg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BP7%2Bxo9DnTitgVjHzpW1ODwRdFruDf%2Bg%2Bisg5pSHT8f27ASvg%40mail.gmail.com
In-Reply-To: <20240904180826.GB15670@t480>

```
On Wed, Sep 4, 2024 at 11:15 AM Rene Kita <mail@rkta.de> wrote:
>
> On Wed, Sep 04, 2024 at 06:49:12PM +0200, Johannes Sixt wrote:
> > Am 04.09.24 um 11:06 schrieb Rene Kita:
> > > I have an alias
> > > 'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
> > > and I would like to be able to sometimes exclude a branch, so call it
> > > with:
> > > $ git gr --exclude=pattern
> > >
> > > This does not work, though. Also does not work without the alias and
> > > typing the complete command by hand. Apparently the --exclude must be
> > > put before the --all to take effect.
> >
> > That is very much by design, so that you can express "branches except
> > the wip and preview branches and remotes except those from the remote
> > archive" with
> >
> > --exclude=wip/* --exclude=preview* --branches --exclude=archive/* --remotes
> >
> > These collective branch options --branches, --remotes, and --all clear
> > the exclude patterns after having them applied. Therefore, in this example,
> > the first two --exclude do not affect --remotes.
>
> OK, certainly not the answer I hoped for, but something I still
> expected. Thanks for the explanation.
>

You could implement this as a shell alias so that your options get
included before the --all. I'm not sure how trivial that would be to
do, but thats how I would go about implementing this alias.

```

## Junio C Hamano, 2024-09-04 20:45

Subject: Re: git log alias with --all and --exclude
Message-ID: <xmqqjzfr87wh.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqjzfr87wh.fsf%40gitster.g
In-Reply-To: <CA+P7+xo9DnTitgVjHzpW1ODwRdFruDf+g+isg5pSHT8f27ASvg@mail.gmail.com>

```
Jacob Keller <jacob.keller@gmail.com> writes:

>> > > 'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
>
> You could implement this as a shell alias so that your options get
> included before the --all. I'm not sure how trivial that would be to
> do, but thats how I would go about implementing this alias.

True.  If I were doing this, I would at least do something like

    [alias]
	rg = "!sh -c 'git log --oneline --abbrev-commit --graph \
		--decorate --color ${1-\"--all\"} \"$@\"' -"

so that

 (1) "git rg" without any argument will default to "--all"
 (2) "git rg --exclude 'wip*' --branches" would work as expected,
     just like "git rg --first-parent master..seen" would.

Thanks.

```

## Rene Kita, 2024-09-05 05:23

Subject: Re: git log alias with --all and --exclude
Message-ID: <20240905052310.GC15670@t480>
URL: https://gitlist.dev/e/20240905052310.GC15670%40t480
In-Reply-To: <xmqqjzfr87wh.fsf@gitster.g>

```
On Wed, Sep 04, 2024 at 01:45:50PM -0700, Junio C Hamano wrote:
> Jacob Keller <jacob.keller@gmail.com> writes:
> 
> >> > > 'gr = log --oneline --abbrev-commit --all --graph --decorate --color'
> >
> > You could implement this as a shell alias so that your options get
> > included before the --all. I'm not sure how trivial that would be to
> > do, but thats how I would go about implementing this alias.
> 
> True.  If I were doing this, I would at least do something like
> 
>     [alias]
> 	rg = "!sh -c 'git log --oneline --abbrev-commit --graph \
> 		--decorate --color ${1-\"--all\"} \"$@\"' -"
> 
> so that
> 
>  (1) "git rg" without any argument will default to "--all"
>  (2) "git rg --exclude 'wip*' --branches" would work as expected,
>      just like "git rg --first-parent master..seen" would.
> 
> Thanks.

Thanks for the ideas, I will adjust my alias.

```
