threads / discuss / 2364

Check for differents trees

Subject: Check for differents trees

## tl;dr

3 messages between Nov 6, 2005 and Nov 6, 2005.

replies: 2people: 3as markdown or json

Marco Costalba· Nov 6, 2005, 15:38 UTC · lore
Hi all,
   I need to check as fast as possible if two given trees (sha1 and sha2) have the same files.
What I use now is:
git-diff-tree -r --name-status sha1 sha2

An then I parse the output for 'A' or 'D' as first char of each line. When I found one of that two chars I kwnow trees have different files set.

The problem is that if sha1 and sha2 correspond to very "distant" revision the output of git-diff-tree can be very long and also usless as long as I stop searching at first match.

My question is if there is a better way, with the constrain of _not_ use a pipe of commands like git-diff-tree....| grep something.

The constrain belong from Qt process class that is not very friendly with shells.
Thanks for any help
Marco
 
		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
Junio C Hamano· Nov 6, 2005, 18:09 UTC · re: Marco Costalba · lore

Re: Check for differents trees

Marco Costalba <mcostalba@yahoo.it> writes:
Show 12 quoted lines
> What I use now is:
>
> git-diff-tree -r --name-status sha1 sha2
>
> An then I parse the output for 'A' or 'D' as first char of
> each line. When I found one of that two chars I kwnow trees
> have different files set.
>
> The problem is that if sha1 and sha2 correspond to very
> "distant" revision the output of git-diff-tree can be very
> long and also usless as long as I stop searching at first
> match.
Perhaps
	$ git-diff-tree -r --name-status --diff-filter=AD sha1 sha2

would help you somewhat? This would not make the diff generation part quicker, but at least you do not have to parse other types of changes.

Johannes Schindelin· Nov 6, 2005, 18:24 UTC · re: Marco Costalba · lore

Re: Check for differents trees

Hi,

if you want to know if tree1 and tree2 have *exactly* the same files, you only have to compare the sha1 of the two trees. If they are equal you are virtually guaranteed that the two trees contain the same files.

Hth, Dscho

← back to recent threads