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

Re: Best way to check whether working tree matches a commit's tree

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Aug 22, 2017, 20:08 UTC
Message-ID
<CAHGBnuPpJtdTBPapFrKcEg6QknBkMjFzwmF0cx9S_2Uo+vp2HA@mail.gmail.com>
In-Reply-To
<xmqqfucj2y7d.fsf@gitster.mtv.corp.google.com>
On Tue, Aug 22, 2017 at 9:34 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> While this works, it feels sub-optimal. Is there a better / smarter way?
>
> I do not think so; you want three things to match and you have a way
> to compare two things at a time.

Right. I was just thinking if there's a lesser known command like "git diff --no-index", but instead of taking two paths, take just one path and a commit.

Show 5 quoted lines
> By the way, I think your second check should compare
>
>         rev-parse HEAD^{tree} $that_commit^{tree}
>
> as you are checking if the tree exactly matches.

In fact, I was considering to use "git diff HEAD $that_commit" as I don't really care whether the SHA1s are equal, but just about the file contents / tree.

-- 
Sebastian Schuberth
Previous: Junio C Hamano
Message 3 of 3 in “Best way to check whether working tree matches a commit's tree”
  1. Sebastian SchuberthAug 22, 2017
  2. Junio C HamanoAug 22, 2017
  3. Sebastian SchuberthAug 22, 2017

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.