# Check for differents trees

3 messages from 2005-11-06 to 2005-11-06. Participants: Marco Costalba, Junio C Hamano, Johannes Schindelin.
Thread: https://gitlist.dev/t/2364

## Marco Costalba, 2005-11-06 15:38

Subject: Check for differents trees
Message-ID: <20051106153830.18963.qmail@web26312.mail.ukl.yahoo.com>
URL: https://gitlist.dev/e/20051106153830.18963.qmail%40web26312.mail.ukl.yahoo.com

```
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, 2005-11-06 18:09

Subject: Re: Check for differents trees
Message-ID: <7vy841y7fl.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy841y7fl.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051106153830.18963.qmail@web26312.mail.ukl.yahoo.com>

```
Marco Costalba <mcostalba@yahoo.it> writes:

> 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, 2005-11-06 18:24

Subject: Re: Check for differents trees
Message-ID: <Pine.LNX.4.63.0511061922570.12750@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511061922570.12750%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051106153830.18963.qmail@web26312.mail.ukl.yahoo.com>

```
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

```
