<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/rev_list_delta_a</filename>
    </added>
    <added>
      <filename>test/fixtures/rev_list_delta_b</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,2 @@
 pkg
+.DS_Store</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -209,6 +209,20 @@ module Grit
       Commit.find_all(self, id, options).first
     end
     
+    # Returns a list of commits that is in +other_repo+ but not in self
+    #
+    # Returns Grit::Commit[]
+    def commit_deltas_from(other_repo, ref = &quot;master&quot;, other_ref = &quot;master&quot;)
+      # TODO: we should be able to figure out the branch point, rather than
+      # rev-list'ing the whole thing
+      repo_refs       = self.git.rev_list({}, ref).strip.split(&quot;\n&quot;)
+      other_repo_refs = other_repo.git.rev_list({}, other_ref).strip.split(&quot;\n&quot;)
+      
+      (other_repo_refs - repo_refs).map do |ref|
+        Commit.find_all(other_repo, ref, {:max_count =&gt; 1}).first
+      end
+    end
+    
     # The Tree object for the given treeish reference
     #   +treeish+ is the reference (default 'master')
     #   +paths+ is an optional Array of directory paths to restrict the tree (deafult [])</diff>
      <filename>lib/grit/repo.rb</filename>
    </modified>
    <modified>
      <diff>@@ -318,4 +318,30 @@ class TestRepo &lt; Test::Unit::TestCase
     Git.any_instance.expects(:log).with({:pretty =&gt; 'raw', :max_count =&gt; 1}, 'master', '--', 'file.rb').returns(fixture('rev_list'))
     @r.log('master', 'file.rb', :max_count =&gt; 1)
   end
+  
+  # commit_deltas_from
+  
+  def test_commit_deltas_from_nothing_new
+    other_repo = Repo.new(GRIT_REPO)
+    @r.git.expects(:rev_list).with({}, &quot;master&quot;).returns(fixture(&quot;rev_list_delta_b&quot;))
+    other_repo.git.expects(:rev_list).with({}, &quot;master&quot;).returns(fixture(&quot;rev_list_delta_a&quot;))
+    
+    delta_commits = @r.commit_deltas_from(other_repo)
+    assert_equal 0, delta_commits.size
+  end
+  
+  def test_commit_deltas_from_when_other_has_new
+    other_repo = Repo.new(GRIT_REPO)
+    @r.git.expects(:rev_list).with({}, &quot;master&quot;).returns(fixture(&quot;rev_list_delta_a&quot;))
+    other_repo.git.expects(:rev_list).with({}, &quot;master&quot;).returns(fixture(&quot;rev_list_delta_b&quot;))
+    %w[
+      4c8124ffcf4039d292442eeccabdeca5af5c5017
+      634396b2f541a9f2d58b00be1a07f0c358b999b3
+      ab25fd8483882c3bda8a458ad2965d2248654335
+    ].each do |ref|
+      Commit.expects(:find_all).with(other_repo, ref, :max_count =&gt; 1).returns([stub()])
+    end
+    delta_commits = @r.commit_deltas_from(other_repo)
+    assert_equal 3, delta_commits.size
+  end
 end</diff>
      <filename>test/test_repo.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ed76397875434609e4db6ececaad28cbe4af4845</id>
    </parent>
  </parents>
  <author>
    <name>Johan S&#248;rensen</name>
    <email>johan@johansorensen.com</email>
  </author>
  <url>http://github.com/mojombo/grit/commit/2adfc816945c1ea2c0f147eef8e46dc3b8596b35</url>
  <id>2adfc816945c1ea2c0f147eef8e46dc3b8596b35</id>
  <committed-date>2009-02-14T02:49:16-08:00</committed-date>
  <authored-date>2009-02-13T03:03:38-08:00</authored-date>
  <message>Added Repo#commit_deltas_from as a (fairly expensive and lazy) way of getting
the commits that differ between two different repositories</message>
  <tree>976245d0e1c7c6030e7a59b22c1dff9171e361eb</tree>
  <committer>
    <name>Johan S&#248;rensen</name>
    <email>johan@johansorensen.com</email>
  </committer>
</commit>
