<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,6 @@ module Grit
     def self.find_all(repo, options = {})
       refs = []
       already = {}
-      git_ruby_repo = GitRuby::Repository.new(repo.path)
 
       Dir.chdir(repo.path) do
         files = Dir.glob(prefix + '/**/*')
@@ -14,15 +13,7 @@ module Grit
 
           id = File.read(ref).chomp
           name = ref.sub(&quot;#{prefix}/&quot;, '')
-          object = git_ruby_repo.get_object_by_sha1(id)
-
-          if object.type == :commit
-            commit = Commit.create(repo, :id =&gt; id)
-          elsif object.type == :tag
-            commit = Commit.create(repo, :id =&gt; object.object)
-          else
-            raise &quot;Unknown object type.&quot;
-          end
+          commit = commit_from_sha(repo, id)
 
           if !already[name]
             refs &lt;&lt; self.new(name, commit)
@@ -31,11 +22,21 @@ module Grit
         end
 
         if File.file?('packed-refs')
-          File.readlines('packed-refs').each do |line|
+          lines = File.readlines('packed-refs')
+          lines.each_with_index do |line, i|
             if m = /^(\w{40}) (.*?)$/.match(line)
               next if !Regexp.new('^' + prefix).match(m[2])
               name = m[2].sub(&quot;#{prefix}/&quot;, '')
-              commit = Commit.create(repo, :id =&gt; m[1])
+
+              # Annotated tags in packed-refs include a reference
+              # to the commit object on the following line.
+              next_line = lines[i+1]
+              if next_line &amp;&amp; next_line[0] == ?^
+                commit = Commit.create(repo, :id =&gt; lines[i+1][1..-1].chomp)
+              else
+                commit = commit_from_sha(repo, m[1])
+              end
+
               if !already[name]
                 refs &lt;&lt; self.new(name, commit)
                 already[name] = true
@@ -47,6 +48,19 @@ module Grit
 
       refs
     end
+
+    def self.commit_from_sha(repo, id)
+      git_ruby_repo = GitRuby::Repository.new(repo.path)
+      object = git_ruby_repo.get_object_by_sha1(id)
+
+      if object.type == :commit
+        Commit.create(repo, :id =&gt; id)
+      elsif object.type == :tag
+        Commit.create(repo, :id =&gt; object.object)
+      else
+        raise &quot;Unknown object type.&quot;
+      end
+    end
   end
 
 end</diff>
      <filename>lib/grit/tag.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,5 +5,6 @@ ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a refs/heads/test/chacon
 2d3acf90f35989df8f262dc50beadc4ee3ae1560 refs/heads/testing
 ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a refs/remotes/origin/master
 2d3acf90f35989df8f262dc50beadc4ee3ae1560 refs/remotes/tom/master
-f0055fda16c18fd8b27986dbf038c735b82198d7 refs/tags/v0.7.0
+f0055fda16c18fd8b27986dbf038c735b82198d7 refs/tags/packed_annotated
 ^7bcc0ee821cdd133d8a53e8e7173a334fef448aa
+ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a refs/tags/packed</diff>
      <filename>test/dot_git/packed-refs</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ class TestTag &lt; Test::Unit::TestCase
   def test_list_from_string
     tags = @r.tags
 
-    assert_equal 3, tags.size
+    assert_equal 5, tags.size
     assert_equal 'not_annotated', tags[1].name
     assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tags[1].commit.id
   end
@@ -20,8 +20,8 @@ class TestTag &lt; Test::Unit::TestCase
   def test_list_from_string_for_signed_tag
     tags = @r.tags
 
-    assert_equal 'v0.7.0', tags.last.name
-    assert_equal '7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tags.last.commit.id
+    assert_equal 'v0.7.0', tags[2].name
+    assert_equal '7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tags[2].commit.id
   end
 
   # list_from_string_for_annotated_tag
@@ -33,6 +33,25 @@ class TestTag &lt; Test::Unit::TestCase
     assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tags.first.commit.id
   end
 
+  # list_from_string_for_packed_tag
+
+  def test_list_from_string_for_packed_tag
+    tags = @r.tags
+
+    assert_equal 'packed', tags[4].name
+    assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', tags[4].commit.id
+  end
+
+  # list_from_string_for_packed_annotated_tag
+
+  def test_list_from_string_for_packed_annotated_tag
+    tags = @r.tags
+
+    assert_equal 'packed_annotated', tags[3].name
+    assert_equal '7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tags[3].commit.id
+  end
+
+
   # inspect
 
   def test_inspect</diff>
      <filename>test/test_tag.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2c178130027e35fbd13db3d1a8ac48538bc8f603</id>
    </parent>
  </parents>
  <author>
    <name>Chris Wanstrath</name>
    <email>chris@ozmm.org</email>
  </author>
  <url>http://github.com/mojombo/grit/commit/a683a584c0056635d15955d4ff2a9566115974ce</url>
  <id>a683a584c0056635d15955d4ff2a9566115974ce</id>
  <committed-date>2009-02-13T15:45:17-08:00</committed-date>
  <authored-date>2009-02-13T15:45:17-08:00</authored-date>
  <message>Add packed-refs annotated tag support.</message>
  <tree>5a06a3c0bc9b503c668f727ac449a131beb95ce4</tree>
  <committer>
    <name>Chris Wanstrath</name>
    <email>chris@ozmm.org</email>
  </committer>
</commit>
