Skip to content
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

'git log --oneline' behaviour is different in GitPython as compared to the same command in Git #1047

Closed
europa502 opened this issue Aug 14, 2020 · 1 comment
Labels

Comments

@europa502
Copy link

@europa502 europa502 commented Aug 14, 2020

So, when I execute 'git log --oneline' I get -

99ace38 (tag: 2.0.52) commit 1                           
8cd6854 commit 2- fix                                                                
bf801d8 (tag: 2.0.51) random commit 1
2f9b046 adding simulated devices                                                                                       
8e4240d Bug fix(sleep)-error fixed for subtest

and 'git log --oneline --nowalk --tags' gives me -

99ace38 (tag: 2.0.52) commit 1                           
8cd6854 (tag: 2.0.51) commit 2- fix                                                                
bf801d8 (tag: 2.0.51) random commit 1
2f9b046 (tag: 2.0.50)adding simulated devices                                                                                       
8e4240d (tag: 2.0.50)Bug fix(sleep)-error fixed for subtest    

The above output is what is desired.
But when I run it from python script I get the result without tags -

repo=Repo(".")
log_lines = repo.git.log('--oneline', '--tags','--no-walk')
>>> log_lines 

99ace38 commit 1                           
8cd6854 commit 2- fix                                                                
bf801d8 random commit 1
2f9b046 adding simulated devices                                                                                       
8e4240d Bug fix(sleep)-error fixed for subtest

I wonder if the GitPython is using git binary and interacting it with via shell?
Is there any way I can get the same output as that from shell?

@Byron Byron added the wont fix label Aug 20, 2020
@Byron
Copy link
Member

@Byron Byron commented Aug 20, 2020

GitPython will connect to the standard output channel of the git log process and read from there.

By the looks of it, git log changes its behaviour when something other than a terminal is connected to it.
Compare git log --color=never --oneline --no-walk --tags | less with git log --color=never --oneline --no-walk --tags.

As git itself uses a pager, it is very able to produce the desired output nonetheless, and I am sure it's just one flag or git config setting away.

I am closing this issue there is it nothing that GitPython to improve the situation. Please feel free to comment for follow ups though.

@Byron Byron closed this Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.