Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I receive an error while trying to use gitpython to check if a repository is dirty, i.e. has uncommitted changed to tracked files:

import git
repo = git.Repo('')
print repo.is_dirty()

The error:

Traceback (most recent call last):
  File "C:\dev\my_prog\test.py", line 8, in <module>
    print repo.is_dirty()
  File "C:\Python27\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\repo\base.py", line 502, in is_dirty
    len(self.git.diff('HEAD', '--cached', *default_args)):
  File "C:\Python27\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\cmd.py", line 227, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\cmd.py", line 456, in _call_process
    return self.execute(call, **_kwargs)
  File "C:\Python27\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\cmd.py", line 377, in execute
    raise GitCommandError(command, status, stderr_value)
git.exc.GitCommandError: 'git diff HEAD --cached --abbrev=40 --full-index --raw' returned exit status 1:

How come? What could be the problem?
Notice I'm working on Windows 7 with msysgit

share|improve this question

1 Answer

Considering the history of diff.py (which hasn't changed much), it is possible that the "git diff HEAD --cached ..." command fails for some reason in your repo.
In other words, it is likely to be linked to your specific local repo than it is to be an implementation issue in the repo.is_dirty() method.

The surest way to debug it is to execute it directly and see what the error message is.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.