Re: Find commit that referenced a blob first

2018-07-19 Thread Stefan Beller
On Thu, Jul 19, 2018 at 3:38 PM Junio C Hamano  wrote:

> > If the given object refers to a blob, it will be described as
> > :,
> > such that the blob can be found at  in the , which itself
> > describes the first commit in which this blob occurs in a reverse
> > revision walk from HEAD.
>
> You walk from the latest to earlier commit (because there by
> definition can be is no reverse pointer from older to newer commit),

but a "reverse walk from HEAD" produces the commits to us in an order
as if we were walking from earlier to latest?


Re: Find commit that referenced a blob first

2018-07-19 Thread Junio C Hamano
Stefan Beller  writes:

> On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider  
> wrote:
>>
>> Hi,
>>
>> I have a blob hash and I would like to know what commit referenced
>> this blob first in a given Git repo.
>
> git describe 
>
> If the given object refers to a blob, it will be described as
> :,
> such that the blob can be found at  in the , which itself
> describes the first commit in which this blob occurs in a reverse
> revision walk from HEAD.

You walk from the latest to earlier commit (because there by
definition can be is no reverse pointer from older to newer commit),
and see if it has the blob, and stop when you find one.  Wouldn't it
generally find the most recent use, not the earliest use as Lars
seems to want?

>
> Since
> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)
> (included first in 2.16.0
>
> You're welcome,
> Stefan


Re: Find commit that referenced a blob first

2018-07-19 Thread Jeff King
On Thu, Jul 19, 2018 at 02:19:34PM -0700, Stefan Beller wrote:

> > I have a blob hash and I would like to know what commit referenced
> > this blob first in a given Git repo.
> 
> git describe 
> 
> If the given object refers to a blob, it will be described as
> :,
> such that the blob can be found at  in the , which itself
> describes the first commit in which this blob occurs in a reverse
> revision walk from HEAD.
> 
> Since
> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)
> (included first in 2.16.0

Hmm.

  $ git describe cfbc47ee2d
  fatal: No tags can describe '83adac3c57ad8cd2c8d44b525414b949950e316d'.
  Try --always, or create some tags.

  $ git describe --always cfbc47ee2d
  83adac3c57:checkout-cache.c

That first output confused me for a moment. We can't produce a nice
descriptive name for the commit in question, so we punt on the whole
thing.

Anyway. I have found your diff --find-object to be more useful in
practice. I.e.:

  git log --find-object=cfbc47ee2d

because I usually care less about a succinct name, and more about
digging into the history (so adding "-p", etc).

-Peff


Re: Find commit that referenced a blob first

2018-07-19 Thread Lars Schneider


> On Jul 19, 2018, at 11:19 PM, Stefan Beller  wrote:
> 
> On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider  
> wrote:
>> 
>> Hi,
>> 
>> I have a blob hash and I would like to know what commit referenced
>> this blob first in a given Git repo.
> 
> git describe 
> 
> If the given object refers to a blob, it will be described as
> :,
> such that the blob can be found at  in the , which itself
> describes the first commit in which this blob occurs in a reverse
> revision walk from HEAD.
> 
> Since
> 644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)
> (included first in 2.16.0
> 
> You're welcome,
> Stefan

Awesome! Thank you very much :-)

- Lars

Re: Find commit that referenced a blob first

2018-07-19 Thread Stefan Beller
On Thu, Jul 19, 2018 at 2:02 PM Lars Schneider  wrote:
>
> Hi,
>
> I have a blob hash and I would like to know what commit referenced
> this blob first in a given Git repo.

git describe 

If the given object refers to a blob, it will be described as
:,
such that the blob can be found at  in the , which itself
describes the first commit in which this blob occurs in a reverse
revision walk from HEAD.

Since
644eb60bd01 (builtin/describe.c: describe a blob, 2017-11-15)
(included first in 2.16.0

You're welcome,
Stefan