git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: get commit ID from a tree object ID

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 26, 2018, 22:21 UTC
Message-ID
<20180326222106.GC21735@aiede.svl.corp.google.com>
In-Reply-To
<CAGZ79kZU39B42BeOxrUDxT6Nca0=Yd+O0TEgu6_HvK3O=b2KhQ@mail.gmail.com>
Hi,
Stefan Beller wrote:
> On Sat, Mar 17, 2018 at 10:57 AM Junio C Hamano <gitster@pobox.com> wrote:
>> Jeff King <peff@peff.net> writes:
Show 19 quoted lines
>>> If you want to dig further, you can use the diff machinery to show which
>>> commit introduced a particular tree, like:
>>>
>>>   git rev-list --all |
>>>   git diff-tree --stdin --pretty=raw --raw -t -r |
>>>   less +/$desired_tree
>>>
>>> That "less" will find the mentioned tree, and then you'll have to
>>> manually read the commit. It would be possible to do it mechanically
>>> with a short perl script, but I'll leave that as an exercise for the
>>> reader.
>
>> Before Stefan jumps in ;-) I wonder if a recently materialized
>> "find-object" option to the diff family can be used here as a
>> sugar-coated way.
>
> I am late to jump in, but testing the 'git log --find-object'
> seems to have issues with trees named by sha1 here,
> but the named tree via <commit>:<path> still seems to work.

Experimenting a little more, I wondered if "-t" wasn't being passed by default:

  $ git --oneline log -t --find-object=$(git rev-parse HEAD~30:Documentation/technical)
  $
No, that's not it.  Could it have to do with merges?
  $ git log --oneline -m --first-parent --find-object=$(git rev-parse HEAD~30:Documentation/technical)
  df6cfe8c30 Merge branch 'debian-experimental' into google3
  f86d5fd2e4 Merge branch 'debian-experimental' into google3
Yes.
That doesn't explain why <commit>:<path> worked for you, though. :)

Thanks, Jonathan

Previous: Stefan Beller
Message 6 of 6 in “get commit ID from a tree object ID”
  1. Michal NovotnyMar 17, 2018
  2. Konstantin KhomoutovMar 17, 2018
  3. Jeff KingMar 17, 2018
  4. Junio C HamanoMar 17, 2018
  5. Stefan BellerMar 26, 2018
  6. Jonathan NiederMar 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.