Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

::describe() fails with depth-cloned + detached head #190

Closed
lukaslueg opened this issue Feb 17, 2017 · 2 comments
Closed

::describe() fails with depth-cloned + detached head #190

lukaslueg opened this issue Feb 17, 2017 · 2 comments

Comments

@lukaslueg
Copy link
Contributor

I have a build on travis failing because of a weird git2 error that happens while trying to get a description from a local repo; roughly this code

use std::path;
extern crate git2;

    match git2::Repository::open(root) {
        Ok(repo) => {
            let mut desc_opt = git2::DescribeOptions::new();
            desc_opt.describe_tags()
                .show_commit_oid_as_fallback(true);
            Ok(Some(repo.describe(&desc_opt).and_then(|desc| desc.format(None))?))
        }
        Err(ref e) if e.class() == git2::ErrorClass::Repository &&
                      e.code() == git2::ErrorCode::NotFound => Ok(None),
        Err(e) => Err(e),
    }

results in

Error { code: -3, klass: 9, message: "object not found - no match for id (77f95f14776deb7e120a2a26f7b56abf2903bc62)" }'

The id 77f95f1 from the error message refers to a commit that is of no particular interest and actually weeks behind; I never asked for it.

I was finally able to reproduce the problem Travis encounters by very carefully following how Travis clones the repo:

git clone --depth=50 https://... crate_root
cd crate_root
git fetch origin +refs/pull/414/merge:
git checkout -qf FETCH_HEAD
cargo test

If and only if the repo is cloned recursively the call to ::describe() results in this error, always referring to 77f95f1. The repo does not even have submodules.

My local git client does the right thing and get's the latest commit oid without problems.

Any idea what's going on here? The issue may be related to this one.

@alexcrichton
Copy link
Member

IIRC libgit2 doesn't support shallow clones, so maybe that's what's going on? This is probably an upstream libgit2 issue unfortunately :(

@lukaslueg
Copy link
Contributor Author

The shallow clone is most likely the reason. There is nothing we can do :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants