You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fetching from remote with explicit refspec raises error incorrectly #396
Passing a refspec to git fetch through a remote, as in repo.remotes.origin.fetch("+refs/heads/*:refs/remotes/origin/*")
will raise an error if the remote has no fetch refspec defined in the config:
AssertionError: Remote '%s' has no refspec set.
You can set it as follows: 'git config --add "remote.origin.fetch +refs/heads/*:refs/heads/*"'.
Also, note that the error message is incorrectly formatted because the remote's name is replaced only in the second line of the message (a %s appears in the first line of the final message).
The _assert_refspec() method should not be called if one or more refspecs were given as arguments to fetch().
Thanks for letting me know - the incorrectly formatted message should now be fixed.
However, I am not quite sure why there is no 'fetch' configuration provided here. In a previous commit it is stated that gitpython needs this to work.
Just not making the assertion should therefore result in a more difficult to debug error. Maybe you can try removing the assertion in question to see if GitPython will work anyway ?
I was testing this briefly and found out that the repo has no fetch refspec because I cloned it as a bare repo. Also, I commented the _assert_refspec() call, tried a fetch, and it worked like a charm.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import git
In [2]: r = git.Repo.clone_from('git://example.com/repos/aletheia.git', 'aletheia.git', branch='develop', bare=True)
In [3]: r.refs
Out[3]:
[<git.Head "refs/heads/develop">,
<git.Head "refs/heads/master">,
<git.TagReference "refs/tags/0.1.0">]
In [4]: r.remotes.origin.fetch('+refs/heads/*:refs/remotes/origin/*')
Out[4]:
[<git.remote.FetchInfo at 0x7feb9e88a940>,
<git.remote.FetchInfo at 0x7feb9e88a998>]
In [5]: r.refs
Out[5]:
[<git.Head "refs/heads/develop">,
<git.Head "refs/heads/master">,
<git.RemoteReference "refs/remotes/origin/develop">,
<git.RemoteReference "refs/remotes/origin/master">,
<git.TagReference "refs/tags/0.1.0">]
So, I would be inclined to conclude that the assertion should only be made if no refspec argument is given:
Activity
fix(remote): asssertion message formatting
Byron commentedon Mar 28, 2016
Thanks for letting me know - the incorrectly formatted message should now be fixed.
However, I am not quite sure why there is no 'fetch' configuration provided here. In a previous commit it is stated that gitpython needs this to work.
Just not making the assertion should therefore result in a more difficult to debug error. Maybe you can try removing the assertion in question to see if GitPython will work anyway ?
rrei commentedon Mar 28, 2016
I was testing this briefly and found out that the repo has no fetch refspec because I cloned it as a bare repo. Also, I commented the
_assert_refspec()call, tried a fetch, and it worked like a charm.So, I would be inclined to conclude that the assertion should only be made if no refspec argument is given:
Are there any impediments to this change?
Byron commentedon Mar 28, 2016
If there are any impediments, then I don't see them.
Would you be fine committing these changes and submit a PR ?
rrei commentedon Mar 28, 2016
Sure, which branch would you like to fork from? (I'll be assuming it is "master" until I hear back from you)
BUG: catch git refspec error, see: gitpython-developers/GitPython#396