* Best way to check whether working tree matches a commit's tree
@ 2017-08-22 18:00 Sebastian Schuberth
2017-08-22 19:34 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Schuberth @ 2017-08-22 18:00 UTC (permalink / raw)
To: git
Hi,
I'd like to check whether my working tree exactly matches the tree of a given commit. That is, there should not be any untracked, staged or modified files (including ignored files).
Currently, I'm doing this in two steps:
- check for success and empty output of "git status --ignored --porcelain"
- check that the output of "git rev-parse HEAD" matches the given commit
While this works, it feels sub-optimal. Is there a better / smarter way?
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Best way to check whether working tree matches a commit's tree
2017-08-22 18:00 Best way to check whether working tree matches a commit's tree Sebastian Schuberth
@ 2017-08-22 19:34 ` Junio C Hamano
2017-08-22 20:08 ` Sebastian Schuberth
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2017-08-22 19:34 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: git
Sebastian Schuberth <sschuberth@gmail.com> writes:
> Hi,
>
> I'd like to check whether my working tree exactly matches the tree of a given commit. That is, there should not be any untracked, staged or modified files (including ignored files).
>
> Currently, I'm doing this in two steps:
>
> - check for success and empty output of "git status --ignored --porcelain"
> - check that the output of "git rev-parse HEAD" matches the given commit
>
> 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.
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Best way to check whether working tree matches a commit's tree
2017-08-22 19:34 ` Junio C Hamano
@ 2017-08-22 20:08 ` Sebastian Schuberth
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Schuberth @ 2017-08-22 20:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
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.
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-22 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 18:00 Best way to check whether working tree matches a commit's tree Sebastian Schuberth
2017-08-22 19:34 ` Junio C Hamano
2017-08-22 20:08 ` Sebastian Schuberth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).