Skip to content

Wrong build order of arguments and options? #70

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
vitorbrandao opened this issue Aug 28, 2012 · 6 comments
Closed

Wrong build order of arguments and options? #70

vitorbrandao opened this issue Aug 28, 2012 · 6 comments

Comments

@vitorbrandao
Copy link

Executing repo.git.stash('save', keep_index=True) turns into:

git.exc.GitCommandError: 'git stash --keep-index save' returned exit status 1: Usage: git stash list [<options>]
   or: git stash show [<stash>]
   or: git stash drop [-q|--quiet] [<stash>]
   or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
   or: git stash branch <branchname> [<stash>]
   or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
                       [-u|--include-untracked] [-a|--all] [<message>]]
   or: git stash clear

The command built by GitPython is git stash --keep-index save.

If using git stash save --keep-index (options first) then this works fine. Thoughts?

@Byron
Copy link
Member

Byron commented Aug 29, 2012

Unfortunately I don't believe this is easy to fix, as the order it uses seems to work for most other commands, whereas a different order doesn't.

However, this was defined with older versions of git, and I remember that I have chosen this particular order on purpose.
Maybe one could fix it by adding a specially recognized flag that will change the order of arguments.

@vitorbrandao
Copy link
Author

You're right. This is an exception to other git commands. Your suggestion of a flag might work just fine. I'll try to send a PR if I find some free time. Thanks for the reply and thanks for this awesome project!

@vitorbrandao
Copy link
Author

How do you build this command git remote update --prune origin? Note prune must be placed after update.

@Byron
Copy link
Member

Byron commented Aug 31, 2012

I don't think it can be build with the current engine, there needs to be a way to reverse the order.

@millerdev
Copy link

Here's a workaround:

repo.git.stash('save', '--keep-index')
repo.git.remote('update', '--prune', 'origin')
repo.git.remote('add', '--mirror=fetch', 'origin', url)

@Byron Byron added this to the v0.3.5 - bugfixes milestone Nov 19, 2014
@Byron
Copy link
Member

Byron commented Jan 9, 2015

I confirm that the only way to control order is to use the string arguments form to invoke the git command, as it will maintain the given ordering of arguments.
This is a suitable workaround for the issue stated here.
Thanks for bringing this up, @millerdev .

@Byron Byron closed this as completed Jan 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants