For SOME files, it happens that in Git Python the g.log() instruction gives error, but for the same file if I do [$git log -- ] on terminal, that works correct. The following command on terminal works very well:
$git log -- org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
Here is my python code:
import git
from git import *
import sys
repo = Repo ("/home/directory/git/eclipse.jdt.core")
assert repo.bare == False
g=repo.git
loginfo = g.log('org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java')
It shows the following error: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py", line 227, in return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py", line 456, in _call_process return self.execute(call, **_kwargs) File "/usr/local/lib/python2.7/dist-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 log org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java' returned exit status 128: fatal: ambiguous argument 'org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'
Can someone please suggest how to correct it?
The --
gets lost in the g.log(...)
call. The correct way to do it would be as follows.
g.log('--', "org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java")