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

checkout by rev hash #112

Closed
CMGS opened this issue Aug 27, 2014 · 2 comments
Closed

checkout by rev hash #112

CMGS opened this issue Aug 27, 2014 · 2 comments

Comments

@CMGS
Copy link
Contributor

CMGS commented Aug 27, 2014

I edit checkout.go and add CheckoutTree method blow, but I don't know why the repo didn't changed after successful execute it.

func (v *Repository) CheckoutTree(treeish string, opts *CheckoutOpts) error {
    var copts C.git_checkout_options
    ptr := populateCheckoutOpts(&copts, opts)

    obj, err := v.RevparseSingle(treeish)
    if err != nil {
        return err
    }
    defer obj.Free()

    commit, err := v.LookupCommit(obj.Id())
    if err != nil {
        return err
    }

    tree, err := commit.Tree()
    if err != nil {
        return err
    }

    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

    ret := C.git_checkout_tree(v.ptr, tree.ptr, ptr)
    if ret < 0 {
        return MakeGitError(ret)
    }

    return nil
}
@carlosmn
Copy link
Member

Without more context, there's no way to know. How are you checking if there's a change? The PR you submitted does not contain tests. Are you trying to checkout files from different trees or always just the current one? You wouldn't see differences in that case.

@CMGS
Copy link
Contributor Author

CMGS commented Aug 28, 2014

It's my fault, checkout_tree method will checkout repo with DRY_RUN Strategy as default. I want to simulate git checkout version to switch master branch to a new version based branch. In this case, just call method with force strategy.

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