Skip to content

random syntax error #257

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
ror6ax opened this issue Feb 12, 2015 · 12 comments
Closed

random syntax error #257

ror6ax opened this issue Feb 12, 2015 · 12 comments

Comments

@ror6ax
Copy link

ror6ax commented Feb 12, 2015

Hi guys,
while working on a project, I met weird behaviour:

repo.git.commit(m="{0},{1},{2}".format(inc,vm,dateexp))
  File "/usr/lib/python2.6/site-packages/git/cmd.py", line 431, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/git/cmd.py", line 802, in _call_process
    return self.execute(make_call(), **_kwargs)
  File "/usr/lib/python2.6/site-packages/git/cmd.py", line 607, in execute
    raise GitCommandError(command, status, stderr_value)
git.exc.GitCommandError: 'git commit -mcommitmessage' returned with exit code 1

Usually it works fine. But once in a while gitpython somehow wants to run -m immidiately followed by message, without the space. Obviously, this fails.

Any ideas on how to overcome this?

Thanks a lot,
Greg

@Byron
Copy link
Member

Byron commented Feb 12, 2015

If short flags are used, it is common practice for unix command to allow aggregating them like it's done here. However, I have never seen this with values. The spot where it happens is this one, which is old code written by Eric Brunson. I am sure he had his reasons to implement it that way, back in the days.

To fix your issue, all you have to do is to make the call like this

repo.git.commit(message="{0},{1},{2}".format(inc,vm,dateexp))

Note the long argument name.
Please let me know if that works for you.

@ror6ax
Copy link
Author

ror6ax commented Feb 13, 2015

Works better, but I've still seen one

raise GitCommandError(command, status, stderr_value)
git.exc.GitCommandError: 'git commit --message=comitmessage' returned with exit code 1

I suspect that sometimes it is not happy with commit messages same like previous ones.
Doing some testing, so commit messages are not really meaningful.

@Byron
Copy link
Member

Byron commented Feb 13, 2015

Something that should always work is if you commit using GitPython itself, like this: repo.index.commit(message=msg) .

@ror6ax
Copy link
Author

ror6ax commented Feb 13, 2015

Well, works for me, so I think this may be closed.
Thanks for help!

@Byron
Copy link
Member

Byron commented Feb 13, 2015

Will do.
It would be good to know which version of gitpython you are using though, just for the record.
Thank you

@Byron Byron closed this as completed Feb 13, 2015
@ror6ax
Copy link
Author

ror6ax commented Mar 2, 2015

I found out that it's the same commit message few times in a row that results in this error.

@Norfeldt
Copy link

Norfeldt commented Aug 3, 2015

I tried all of the above and still can't commit anything.. even leaving out the messange and doing something like m = ' " my message " ' nor did it work...

@Byron
Copy link
Member

Byron commented Aug 3, 2015

It's also possible to do something like this: repo.git.commit('-m', 'hello world'), which enforces the given order without any contraction.

@ror6ax
Copy link
Author

ror6ax commented Aug 4, 2015

@Norfeldt - try committing with different message. Seriously, this is a bug I have in script which is run 15 times a day.

@Byron - this is a reoccuring error. I can try and debug it if you are willing to reopen issue and add the fix when we find it.

@ror6ax
Copy link
Author

ror6ax commented Aug 4, 2015

My errors always lead to https://github.com/gitpython-developers/GitPython/blob/master/git/cmd.py#L440 in the stacktrace. @Norfeldt - can you confirm?

I went to look into commit function code and was surprised stacktrace does not actually go into it.

@Byron
Copy link
Member

Byron commented Aug 8, 2015

Maybe you don't have the git command in your PATH ? It should be possible to execute git in the shell/environment that is used with GitPython. In case this is indeed not the case, you can point GitPython to the executable by setting the GIT_PYTHON_GIT_EXECUTABLE to the full git executable path.

Additional debugging can be performed by setting the GIT_PYTHON_TRACE to full, which will output all git command invocations and their output.

@Norfeldt
Copy link

Norfeldt commented Aug 9, 2015

First off all: thank you for the fast replies, sorry I haven't been able to reply with the same speed.

I believe I had the same issues as PTBNL and then I implemented Billy Jin answer in my code - that worked.

I rewrote the code to use gitpython again, and now it's working..
I do not understand
The weird thing is that the print repo.git.status() was always working as it should. But it was the commit that was giving me the trouble..

@ror6ax I believe that it was L440 that was written in the error. But I cannot confirm it, since it's working now..

(BTW I using windows 7.)

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

3 participants