Skip to content

Conversation

Yogu
Copy link
Contributor

@Yogu Yogu commented Mar 3, 2014

This implements git clone --recursive by performing the following steps:

  • Clone repository normally
  • For each submodule
    • Init repository with git_repository_init_ext to explicitly specify workdir and .git dir
    • git_clone_into with checkout disabled
    • Checkout the HEAD id and reset hard
    • For each submodule... (recursively)

This is a work in progress.

@Yogu Yogu mentioned this pull request Mar 3, 2014
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes, native methods specify ref here for no apparent reason. Is it required here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually this is used when the native signature uses a git_oid*. GitOid is a struct on the managed side, so to get a "pointer" to it, you use ref.

Pretty sure that's how it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, most arguments to native methods use reference types. Curiously enough, it still works without ref.

@Yogu
Copy link
Contributor Author

Yogu commented Mar 3, 2014

hm, travis did not find the new repository. Do I have to add new resources somewhere?

@Yogu
Copy link
Contributor Author

Yogu commented Mar 3, 2014

What should we do if the init/update fails? I'd say, revert everything, i.e. delete the directory of the main repo.

Should we expose Submodule.Init/Update? They would need to do more checks, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether it is intended, but git_repository_init_ext adds a .git to the gitdirPath. It will still work, but it would be better if the repo was in .git/modules/name instead of .git/modules/name/.git/. Do you know how to achieve that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you can add the GIT_REPOSITORY_INIT_NO_DOTGIT_DIR flag to achieve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ben
Copy link
Member

ben commented Mar 4, 2014

travis did not find the new repository

Yeah, you'll have to add your new test repo to the LibGit2Sharp.Tests/Resources directory.

@Yogu
Copy link
Contributor Author

Yogu commented Mar 4, 2014

Thanks for your feedback, @ben!

you'll have to add your new test repo to the LibGit2Sharp.Tests/Resources directory.

I did, and it works locally, but travis says

Could not find repository from '/home/travis/build/libgit2/libgit2sharp/LibGit2Sharp.Tests/bin/Release/Resources/58f90cab-8f49-4123-a4e8-cda1488a097d/submodules.git'

Maybe that's a linux-specific problem, I can only test on Windows.

@carlosmn
Copy link
Member

carlosmn commented Mar 7, 2014

It's not anything about Linux, it's just that what you have locally is not what's in the history. The submodules.git/refs/ directory is presumably empty in your filesystem, but it's still there. Git doesn't track those, so when it's put on the filesystem on checkout, that dir is not there.

If you clone your repo locally, you should see the same error as on travis.

@Yogu
Copy link
Contributor Author

Yogu commented Mar 7, 2014

@carlosmn Ah, thanks! That fixed it. The build still fails because of getAbsoluteUrl() which I want to get rid of eventually.

Added CloneOptions.Recursive to specify whether submodules should be
initialized and updated after checkout
@nulltoken
Copy link
Member

Superseded by #949

Cheers!

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

Successfully merging this pull request may close these issues.

4 participants