GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

Feature Request: git log for specific directories

Open ben-en opened this issue 11 years ago • 2 comments

I'd really like to be able to do either of the following, assuming the current directory is a git repo; git.repo().heads.master.log(DIR) git.repo().git('log -- DIR')

Using git log --pretty=format:%H -- master results in the following output:

$ git log --pretty=format:%H -- master
526356389b024590def5df5a7e1be70b2076835a
02b3a074587a97e673de55c3e35418952a9a40c6
5c12fdf5708633eb98b88d681907748a3e0090f8
...
0d381427d1d3f65e009b27abff95d016fb134ef6

In the same directory from interactive python3 prompt using git.Repo().git.log('--pretty=format:%h -- master') does not understand -- master;

>>> import git
>>> git.Repo().git.log('--pretty=format:%h -- master')
'808810fbfc4bd58891e43fa641e0bb6137c3fc97 -- master\na8be92733c87b09c1592fdb7200633f9fee0354d -- master\n09e7a7be446393052923b2baf72537cbd1d5bf6a -- master\n79c9c62d92d13755cdc398c33249176b77047e38 -- master\n...

ben-en avatar Jul 01 '15 17:07 ben-en

What if you try it this way instead: git.Repo().git.log('--pretty=format:%h', '--', 'master').

Please let me know if this solves the issue.

Byron avatar Jul 01 '15 17:07 Byron

Thanks for the fast response, that did the trick! I had been trying to do it git('log --flag -- dir') which obviously does not work. I'm not sure how i managed to think that the "only takes one argument" error applied to git.log() as well.

ben-en avatar Jul 01 '15 17:07 ben-en