How do I do a recursive clone with git2go? #287

Closed
opened 2016-01-30 00:15:31 -06:00 by roonyh · 1 comment
roonyh commented 2016-01-30 00:15:31 -06:00 (Migrated from github.com)

How do I do a recursive clone with git2go? When the operation is completed I want the files of the repo and the submodule to be in the working directory.

in git I do this by

git clone http://www.github.com/roonyh/blog
git checkout master
git submodule init
git submodule update

In git2go I have tried this after clonning,

    repo.Submodules.Foreach(func(sub *git.Submodule, name string) int {
        fmt.Println(name) // prints the name of the only submodule I have
        sub.Init(true)
        err := sub.Update(true, &git.SubmoduleUpdateOptions{
            &git.CheckoutOpts{
                Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules,
            },
            &git.FetchOptions{},
            git.CheckoutForce | git.CheckoutUpdateSubmodules,
        })
                fmt.Println(err) // prints an error given below
        return 0
    })

The error on the Update call reads, Object not found - no match for id (9be04b37f879b6680bfa5f1476a01ba2c1619036).

I am able to get the files via git though.

And this while cloning.

    co := &git.CloneOptions{
        CheckoutOpts: &git.CheckoutOpts{
            Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules,
        },
        CheckoutBranch: "master",
    }
    repo, err := git.Clone(url, path, co)
    if err != nil {
        fmt.Print(err)
    }

But the submodule's files are not in the working directory.

Sorry if this is not the appropriate place for questions. And is there any place where information like this documented?

How do I do a recursive clone with git2go? When the operation is completed I want the files of the repo and the submodule to be in the working directory. in git I do this by ``` git clone http://www.github.com/roonyh/blog git checkout master git submodule init git submodule update ``` In git2go I have tried this after clonning, ``` go repo.Submodules.Foreach(func(sub *git.Submodule, name string) int { fmt.Println(name) // prints the name of the only submodule I have sub.Init(true) err := sub.Update(true, &git.SubmoduleUpdateOptions{ &git.CheckoutOpts{ Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules, }, &git.FetchOptions{}, git.CheckoutForce | git.CheckoutUpdateSubmodules, }) fmt.Println(err) // prints an error given below return 0 }) ``` The error on the Update call reads, `Object not found - no match for id (9be04b37f879b6680bfa5f1476a01ba2c1619036)`. I am able to get the files via git though. And this while cloning. ``` go co := &git.CloneOptions{ CheckoutOpts: &git.CheckoutOpts{ Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules, }, CheckoutBranch: "master", } repo, err := git.Clone(url, path, co) if err != nil { fmt.Print(err) } ``` But the submodule's files are not in the working directory. Sorry if this is not the appropriate place for questions. And is there any place where information like this documented?
roonyh commented 2016-01-30 20:06:44 -06:00 (Migrated from github.com)

never mind. There was a problem with the repo of the submodule.

never mind. There was a problem with the repo of the submodule.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#287
No description provided.