]> git.proxmox.com Git - cargo.git/commitdiff
Find objects instead of tags.
authorAlex Crichton <alex@alexcrichton.com>
Sun, 4 Jan 2015 06:45:58 +0000 (22:45 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 4 Jan 2015 06:45:58 +0000 (22:45 -0800)
It looks like tags don't always point to tag objects, but rather sometimes to
commits themselves. This tweaks the peeling logic for tags to find an *object*
first, and then peel to a commit, rather than finding a tag first and then
peeling.

Closes #1119

src/cargo/sources/git/utils.rs

index 1f6c0aed89b38b902f4926fc96cf00ce5c3b0c3a..3db7e9ed73b1c2b1ac8faab234b8f98850290952 100644 (file)
@@ -3,7 +3,7 @@ use std::io::{USER_DIR};
 use std::io::fs::{mkdir_recursive, rmdir_recursive, PathExtensions};
 use rustc_serialize::{Encodable, Encoder};
 use url::Url;
-use git2;
+use git2::{mod, ObjectType};
 
 use core::GitReference;
 use util::{CargoResult, ChainError, human, ToUrl, internal};
@@ -185,8 +185,8 @@ impl GitDatabase {
                 try!((|:| {
                     let refname = format!("refs/tags/{}", s);
                     let id = try!(self.repo.refname_to_id(refname.as_slice()));
-                    let tag = try!(self.repo.find_tag(id));
-                    let obj = try!(tag.peel());
+                    let obj = try!(self.repo.find_object(id, None));
+                    let obj = try!(obj.peel(ObjectType::Commit));
                     Ok(obj.id())
                 }).chain_error(|| {
                     human(format!("failed to find tag `{}`", s))