Skip to content

How to use git command 'git log -p' with GitPython #157

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
fengqiaoye opened this issue May 2, 2014 · 8 comments
Closed

How to use git command 'git log -p' with GitPython #157

fengqiaoye opened this issue May 2, 2014 · 8 comments

Comments

@fengqiaoye
Copy link

I need use GitPython to do one command, the look like git command " git log -p".
I read the tutorial but I still don't know how to do it .
I use the command master.log() ,but couldn't return what the program changed.

@fengqiaoye
Copy link
Author

someone can help me ?

@Byron
Copy link
Member

Byron commented May 2, 2014

git-python usually calls the git command and parses its output for easy consumption by a python program. However, the respective functionality is implemented only for a small subset of commands.

In your case, you should be able to read all the output with something like this

r = git.Repo('.')
r.git.log(p=True)

Now it's up to you to make sense of the returned string.

@Byron Byron added the feedback label May 2, 2014
@fengqiaoye
Copy link
Author

Think you for your help!
but i has been try it , it couldn't solve it.
the result like this:

import git
repo = git.Repo(r"F:/program/GitPro/testspro/")
repo.git.log(p=True)

Traceback (most recent call last):
File "<pyshell#2>", line 1, in
repo.git.log(p=True)
File "F:\Program Files\python-2.7.5.amd64\lib\site-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 "F:\Program Files\python-2.7.5.amd64\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 "F:\Program Files\python-2.7.5.amd64\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\cmd.py", line 335, in execute
*_subprocess_kwargs
File "F:\Program Files\python-2.7.5.amd64\lib\subprocess.py", line 711, in init
errread, errwrite)
File "F:\Program Files\python-2.7.5.amd64\lib\subprocess.py", line 948, in _execute_child
startupinfo)
WindowsError: [Error 2]

@Byron
Copy link
Member

Byron commented May 2, 2014

Did you install git-python ? If so, please make sure it is in your PATH.

@fengqiaoye
Copy link
Author

yes.
if I couldn't install GitPython .you can't see this error :
File "F:\Program Files\python-2.7.5.amd64\lib\site-packages\gitpython-0.3.2.rc1-py2.7.egg\git\cmd.py", line 335, in execute

if not install ,the program will print error no module for git

@fengqiaoye
Copy link
Author

I checked it now ,i has been install this module.

@fengqiaoye
Copy link
Author

Think you very much ,Byron!
now I solve it ! because i not add git in my PATH.
when you use :
git.log(p=True)
is use cmd.py:
class Git()
def _call_process(self, method, _args, *_kwargs):
#in this program have one argument call:
call = [self.GIT_PYTHON_GIT_EXECUTABLE, dashify(method)]
#I search GIT_PYTHON_GIT_EXECUTABLE in this module(cmd.py)

find in line 55:

Provide the full path to the git executable. Otherwise it assumes git is in the path

GIT_PYTHON_GIT_EXECUTABLE = os.environ.get("GIT_PYTHON_GIT_EXECUTABLE", 'git')

I think may be this module use cmd open git do command , but couldn't find the Git program.so raise error.

@Byron Byron closed this as completed May 2, 2014
@fengqiaoye
Copy link
Author

add the
'/the git program path/Git/bin' and '/the git program path/Git/libexec/git-core'
in my PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants