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

create_submodule with branch 'master' gets error on submodule update #585

Open
idij opened this issue Feb 16, 2017 · 2 comments
Open

create_submodule with branch 'master' gets error on submodule update #585

idij opened this issue Feb 16, 2017 · 2 comments

Comments

@idij
Copy link

idij commented Feb 16, 2017

Not sure if this is a real issue, or a failure in my understanding, but anyway:

In an automation script, I clone a GitHub repo,

repo = git.Repo.clone_from (repo_url, repo_path, branch='master')

and create_submodule with the branch set to 'master'

repo.create_submodule (name=submodule_path, path=submodule_path, submodule_url=url, branch='master', no_checkout=True)

This succeeds ok, although what is written to the .gitmodules is branch = origin/refs/heads/master
The submodule_path is 2 levels deep, like e.g. 'imports/module_a' or similar
I commit & push that change.

On my dev machine I clone the repo with the newly added submodule:

git clone <url> workspace
cd workspace
git submodule init
git submodule update --remote

The last command gets an error:

fatal: needed a single revision
unable to find current origin/refs/heads/master revision in submodule path 'path/to/submodule'

If I do it all manually using:

git submodule add -b master <url> <path>

Then what gets written to .gitmodules is branch = master and on the submodule update there is no error, and master updates fine.

@Byron
Copy link
Member

Byron commented Feb 25, 2017

I believe that this code is responsible for resolving to full paths.

The submodule system in GitPython was written to extend the implementation that git provided. Back in those days, git would not support the branch keyword at all, so it would just be ignored. Now it is picked up, and might not be what the git-submodule implementation expects.

Nevertheless, origin/refs/heads/master is usually a none-existing and incorrect branch path, and I don't know how that came to be.

@idij
Copy link
Author

idij commented Mar 8, 2017

As a workaround, the following seems to work:

submodule.config_writer().set_value('branch', 'master')

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

No branches or pull requests

2 participants