Skip to content

Default branch is appended to git checkout command, causing error #106

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

Closed
jasondunsmore opened this issue Apr 22, 2013 · 1 comment
Closed

Comments

@jasondunsmore
Copy link

Whenever I attempt to use the checkout method, the default branch is appended to the git checkout command. Furthermore, there needs to be a space between the -f option and the branch/ref. Here are some examples:

In [8]: git.Repo.clone_from("git://github.com/gitpython-developers/GitPython.git", "/tmp/git-test").heads[0].checkout('0.3')
---------------------------------------------------------------------------
GitCommandError                           Traceback (most recent call last)
<ipython-input-8-5c49227b8211> in <module>()
----> 1 git.Repo.clone_from("git://github.com/gitpython-developers/GitPython.git", "/tmp/git-test").heads[0].checkout('0.3')

/home/jason/github/gitpython/git/refs/headref.pyc in checkout(self, force, **kwargs)
    164                         kwargs.pop('f')
    165 
--> 166                 self.repo.git.checkout(self, **kwargs)
    167                 return self.repo.active_branch
    168 

/home/jason/github/gitpython/git/cmd.pyc in <lambda>(*args, **kwargs)
    236                 if name[0] == '_':
    237                         return LazyMixin.__getattr__(self, name)
--> 238                 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
    239 
    240         def _set_cache_(self, attr):

/home/jason/github/gitpython/git/cmd.pyc in _call_process(self, method, *args, **kwargs)
    502                         #END provide better error message
    503                 else:
--> 504                         return self.execute(make_call(), **_kwargs)
    505                 #END handle windows default installation
    506 

/home/jason/github/gitpython/git/cmd.pyc in execute(self, command, istream, with_keep_cwd, with_extended_output, with_exceptions, as_process, output_stream, output_strip, **subprocess_kwargs)
    395 
    396                 if with_exceptions and status != 0:
--> 397                         raise GitCommandError(command, status, stderr_value)
    398 
    399                 # Allow access to the command's status code

GitCommandError: 'git checkout -f0.3 0.3' returned exit status 129: error: unknown switch `0'
usage: git checkout [options] <branch>
   or: git checkout [options] [<branch>] -- <file>...

    -q, --quiet           be quiet
    -b <new branch>       branch
    -l                    log for new branch
    -t, --track           track
    --orphan <new branch>
                          new unparented branch
    -2, --ours            stage
    -3, --theirs          stage
    -f, --force           force
    -m, --merge           merge
    --conflict <style>    conflict style (merge or diff3)
    -p, --patch           select hunks interactively


In [11]: git.Repo.clone_from("git://github.com/gitpython-developers/GitPython.git", "/tmp/git-test0").heads[0].checkout('master')
---------------------------------------------------------------------------
GitCommandError                           Traceback (most recent call last)
<ipython-input-11-2828cd151765> in <module>()
----> 1 git.Repo.clone_from("git://github.com/gitpython-developers/GitPython.git", "/tmp/git-test0").heads[0].checkout('master')

/home/jason/github/gitpython/git/refs/headref.pyc in checkout(self, force, **kwargs)
    164                         kwargs.pop('f')
    165 
--> 166                 self.repo.git.checkout(self, **kwargs)
    167                 return self.repo.active_branch
    168 

/home/jason/github/gitpython/git/cmd.pyc in <lambda>(*args, **kwargs)
    236                 if name[0] == '_':
    237                         return LazyMixin.__getattr__(self, name)
--> 238                 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
    239 
    240         def _set_cache_(self, attr):

/home/jason/github/gitpython/git/cmd.pyc in _call_process(self, method, *args, **kwargs)
    502                         #END provide better error message
    503                 else:
--> 504                         return self.execute(make_call(), **_kwargs)
    505                 #END handle windows default installation
    506 

/home/jason/github/gitpython/git/cmd.pyc in execute(self, command, istream, with_keep_cwd, with_extended_output, with_exceptions, as_process, output_stream, output_strip, **subprocess_kwargs)
    395 
    396                 if with_exceptions and status != 0:
--> 397                         raise GitCommandError(command, status, stderr_value)
    398 
    399                 # Allow access to the command's status code

GitCommandError: 'git checkout -fmaster 0.3' returned exit status 129: error: unknown switch `a'
usage: git checkout [options] <branch>
   or: git checkout [options] [<branch>] -- <file>...

    -q, --quiet           be quiet
    -b <new branch>       branch
    -l                    log for new branch
    -t, --track           track
    --orphan <new branch>
                          new unparented branch
    -2, --ours            stage
    -3, --theirs          stage
    -f, --force           force
    -m, --merge           merge
    --conflict <style>    conflict style (merge or diff3)
    -p, --patch           select hunks interactively

In the first example, I expected the command to be git checkout -f 0.3 and in the second example, I expected the command to be git checkout -f master.

This happens with both the 0.3 branch and the master branch. Let me know if you need any other info.

@Byron
Copy link
Member

Byron commented Nov 19, 2014

I could not reproduce this one, your example line worked fine for me. I am using git-python 0.3.2.1 and git 1.9.3.
Please leave a comment if it's still an issue for you.

@Byron Byron closed this as completed Nov 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants