Git development
 help / color / mirror / Atom feed
* Check for differents trees
@ 2005-11-06 15:38 Marco Costalba
  2005-11-06 18:09 ` Junio C Hamano
  2005-11-06 18:24 ` Johannes Schindelin
  0 siblings, 2 replies; 7+ messages in thread
From: Marco Costalba @ 2005-11-06 15:38 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Check for differents trees
@ 2005-11-06 19:02 Marco Costalba
  2005-11-08 17:13 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Costalba @ 2005-11-06 19:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:

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

Thanks Junio,

   as you said, the speed is almost the same but your way is clearly better.

I have pushed the change.

P.S.: Could be interesting something like?:
     
          git-diff-tree -r --name-status --diff-filter=^M sha1 sha2


                          -------------------

>Dscho says:
>
>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.


I have impemented a tree viewer inside qgit. Tree view is updated when user browses through
revisions.

Loading the file names of a given tree, altough only for the open directories, is an expensive
operation. So I added a little "same files" test to skip tree reloading.

With "same files" I mean that the file list is the same bewteen tree1 and tree1, _not_ that the
files content are the same. As example, if tree1 is parent of tree2 (and tree2 is not a merge) and
the revision between the two only modified files (git-diff-tree status is M), in my test tree1 and
tree2 have the same files, also if sha's are, of course, different.

Put in other way, two trees have the "same files" if I don't have to repaint the tree view window.

  Marco
 


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Check for differents trees
@ 2005-11-10  6:35 Marco Costalba
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Costalba @ 2005-11-10  6:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:

>Marco Costalba <mcostalba@yahoo.it> writes:
>
>>   as you said, the speed is almost the same but your way is clearly better.
>
>
>How often do you do this --diff-filter=AD and why?
>
>If it is a common enough operation, we could add a specific hack
>to stop feeding the diff machinery with unwanted kind of changes
>when diff-filter is set and none of -B/-C/-M are used.  That
>_might_ speed things up for you.
>

Sorry for late answer byt I was off line a few days.

Thanks, It will be great.

I have impemented a tree viewer for qgit. Tree view is updated when user browses through
revisions. Loading the file names of a given tree, altough only for the open directories, is an
expensive operation. So I check for different files anytime the user select a new revision and
the tree viewer is open, I use this test to skip tree reloading if trees have the same files.

I have made some speed test with 
git-diff-tree -r --name-status --diff-filter=AD sha1 sha2



  Marco



		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Check for differents trees
@ 2005-11-10  6:57 Marco Costalba
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Costalba @ 2005-11-10  6:57 UTC (permalink / raw)
  To: junkio; +Cc: git

Junio C Hamano wrote:

>Marco Costalba <mcostalba@yahoo.it> writes:
>
>>   as you said, the speed is almost the same but your way is clearly better.
>
>
>How often do you do this --diff-filter=AD and why?
>
>If it is a common enough operation, we could add a specific hack
>to stop feeding the diff machinery with unwanted kind of changes
>when diff-filter is set and none of -B/-C/-M are used.  That
>_might_ speed things up for you.
>

Sorry for late answer but I was off line a few days.

QGit has a tree viewer now. Tree view is updated when user browses through revisions. Loading the
file names of a given tree, although only for the open directories, is an expensive operation. So
qgit checks for different files anytime the user selects a new revision and the tree viewer is
open, I use this test to skip tree reloading if trees have the same files.

I have made some speed test on Linux tree with 
       git-diff-tree -r --name-status --diff-filter=AD sha1 sha2

On my box it takes from 50-100ms for near revisions to almost 2 seconds when you select a new
revision very far from current one. Add to this the fact that in distant revs case there is a high
probability that the trees are found different, so you need also to reload the tree at the end,
adding extra time before GUI update.

So definitely, It will be great to keep tree browsing snappy. I speak for qgit, but I think any
git viewer that adds tree browsing feature should benefit from this change.


  Marco

P.S: By the way, if I understand correctly, what you propone is a different behavior of
--diff-filter=AD. Not to filter for AD, but to find first match of AD. Because of this, IMHO
should be better to have a --first-match=AD flag or, better idea, to use --max-count option (from
git-rev-list) togheter with --diff-filter and have something like:

git-diff-tree -r --name-status --diff-filter=AD --max-count=1 sha1 sha2




	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-10  6:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-06 15:38 Check for differents trees Marco Costalba
2005-11-06 18:09 ` Junio C Hamano
2005-11-06 18:24 ` Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2005-11-06 19:02 Marco Costalba
2005-11-08 17:13 ` Junio C Hamano
2005-11-10  6:35 Marco Costalba
2005-11-10  6:57 Marco Costalba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox