# Do we have a convenient way to refer to a specific commit in an already filtered rev-list?

5 messages from 2011-09-24 to 2011-10-04. Participants: Tzu-Jung Lee, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/28482

## Tzu-Jung Lee, 2011-09-24 16:46

Subject: Do we have a convenient way to refer to a specific commit in an already filtered rev-list?
Message-ID: <CAEvN+1jPD53-e8a31g+iz6vMB0-e2LECjouBELkBOXBV5=oGBg@mail.gmail.com>
URL: https://gitlist.dev/e/CAEvN%2B1jPD53-e8a31g%2Biz6vMB0-e2LECjouBELkBOXBV5%3DoGBg%40mail.gmail.com

```
Hi Folks,

Do we have a convenient/symbolic way to refer  to a specific commit of
an already filtered rev-list? For example, I'm interested in the
commits with some constraints:

    git log somepath --author=someone

Without gui/tui tools, I have to frequently CUT & PASTE the commit-ID
for further manipulation (show, cherry-pick, ...), and possibly repeat
the parsing couple of times if I didn't save the output. I wonder if
we have a convenient way to refer to the discrete commits? like
HEAD~4, HEAD@{3} or something magic.

Thanks,
Roy

```

## Jeff King, 2011-09-27 21:35

Subject: Re: Do we have a convenient way to refer to a specific commit in an already filtered rev-list?
Message-ID: <20110927213517.GB5176@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20110927213517.GB5176%40sigill.intra.peff.net
In-Reply-To: <CAEvN+1jPD53-e8a31g+iz6vMB0-e2LECjouBELkBOXBV5=oGBg@mail.gmail.com>

```
On Sun, Sep 25, 2011 at 12:46:20AM +0800, Tzu-Jung Lee wrote:

> Do we have a convenient/symbolic way to refer  to a specific commit of
> an already filtered rev-list? For example, I'm interested in the
> commits with some constraints:
> 
>     git log somepath --author=someone
> 
> Without gui/tui tools, I have to frequently CUT & PASTE the commit-ID
> for further manipulation (show, cherry-pick, ...), and possibly repeat
> the parsing couple of times if I didn't save the output. I wonder if
> we have a convenient way to refer to the discrete commits? like
> HEAD~4, HEAD@{3} or something magic.

Use the shell:

  git rev-list --author=someone HEAD >saved-query
  git log --no-walk --stdin <saved-query
  git cherry-pick `cat saved-query`

or even:

  q=`git rev-list --author=someone HEAD`
  git log --no-walk $q
  git cherry-pick $q

-Peff

```

## Tzu-Jung Lee, 2011-10-03 17:19

Subject: Re: Do we have a convenient way to refer to a specific commit in an already filtered rev-list?
Message-ID: <CAEvN+1gODnGy2v2=d6NXJ8b1nBJgpqj+BkDm2eQC1xqyTKXhEg@mail.gmail.com>
URL: https://gitlist.dev/e/CAEvN%2B1gODnGy2v2%3Dd6NXJ8b1nBJgpqj%2BBkDm2eQC1xqyTKXhEg%40mail.gmail.com
In-Reply-To: <20110927213517.GB5176@sigill.intra.peff.net>

```
On Wed, Sep 28, 2011 at 5:35 AM, Jeff King <peff@peff.net> wrote:
> On Sun, Sep 25, 2011 at 12:46:20AM +0800, Tzu-Jung Lee wrote:
>
>> Do we have a convenient/symbolic way to refer  to a specific commit of
>> an already filtered rev-list? For example, I'm interested in the
>> commits with some constraints:
>>
>>     git log somepath --author=someone
>>
>> Without gui/tui tools, I have to frequently CUT & PASTE the commit-ID
>> for further manipulation (show, cherry-pick, ...), and possibly repeat
>> the parsing couple of times if I didn't save the output. I wonder if
>> we have a convenient way to refer to the discrete commits? like
>> HEAD~4, HEAD@{3} or something magic.
>
> Use the shell:
>
>  git rev-list --author=someone HEAD >saved-query
>  git log --no-walk --stdin <saved-query
>  git cherry-pick `cat saved-query`
>
> or even:
>
>  q=`git rev-list --author=someone HEAD`
>  git log --no-walk $q
>  git cherry-pick $q
>
> -Peff
>

Cool, this does record and replay.


How about adding a command or teaching some existing one an option
like --saved=<ref_name>, which put the saved-list to
refs/saved/<ref_name> ?
And also teach the rev-list to parse or interpret the 'saved' refs differently.
So we can have the following use case:

   git log branch_foo --author=some_one -S some_string --saved=cached_ref
   git log cached_ref
   git cherry-pick cached_ref~4
   git format-patch cached_ref~6..cached_ref~2

I often have such use cases. not sure others would be benefited from
such feature.
Just asking for comment. :)

Regards,
Roy

```

## Junio C Hamano, 2011-10-03 19:40

Subject: Re: Do we have a convenient way to refer to a specific commit in an already filtered rev-list?
Message-ID: <7v1uutg8xw.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1uutg8xw.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAEvN+1gODnGy2v2=d6NXJ8b1nBJgpqj+BkDm2eQC1xqyTKXhEg@mail.gmail.com>

```
Tzu-Jung Lee <roylee17@gmail.com> writes:

> And also teach the rev-list to parse or interpret the 'saved' refs differently.
> So we can have the following use case:
>
>    git log branch_foo --author=some_one -S some_string --saved=cached_ref
>    git log cached_ref
>    git cherry-pick cached_ref~4
>    git format-patch cached_ref~6..cached_ref~2
>
> I often have such use cases. not sure others would be benefited from
> such feature.
> Just asking for comment. :)

It feels too much hackery for too little gain.

$ git log --oneline master..branch --author=A.U.Thor -Spickaxe >foos.txt

and working from the text file foos.txt at least would not contaminate any
ref namespace and you do not have to clean them after you are done.

```

## Jeff King, 2011-10-04 07:05

Subject: Re: Do we have a convenient way to refer to a specific commit in an already filtered rev-list?
Message-ID: <20111004070529.GA6916@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20111004070529.GA6916%40sigill.intra.peff.net
In-Reply-To: <7v1uutg8xw.fsf@alter.siamese.dyndns.org>

```
On Mon, Oct 03, 2011 at 12:40:43PM -0700, Junio C Hamano wrote:

> Tzu-Jung Lee <roylee17@gmail.com> writes:
> 
> > And also teach the rev-list to parse or interpret the 'saved' refs differently.
> > So we can have the following use case:
> >
> >    git log branch_foo --author=some_one -S some_string --saved=cached_ref
> >    git log cached_ref
> >    git cherry-pick cached_ref~4
> >    git format-patch cached_ref~6..cached_ref~2
> >
> > I often have such use cases. not sure others would be benefited from
> > such feature.
> > Just asking for comment. :)
> 
> It feels too much hackery for too little gain.

Agreed. It means that each entry in refs/saved is subtly _not_ a ref,
but rather a list of refs. Until now, most refs are considered equal
with respect to basic things like ref lookup.  So if git were to save
this, I'm not sure refs/ would be the right place. A reflog would be a
bit closer in concept.

But I really don't see the need for git to handle this at all. There is
already a general solution:

> $ git log --oneline master..branch --author=A.U.Thor -Spickaxe >foos.txt
> 
> and working from the text file foos.txt at least would not contaminate any
> ref namespace and you do not have to clean them after you are done.

Which works just as well, and is way more flexible. You have to be a
little more proficient in using the shell, but that is at least a
general skill which transfers to many other programs.

-Peff

```
