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
The result of git.Git.show (...) misses newlines ("\n") at the end of a file.
Reproduction
# commits = ... repo.git.show(f"{commits[0].hexsha}:{testfile}")
git show 74e70e7:foo.txt | cat -vet | less
Observation
The string returned from show via GitPython has a trailing "\r", missing the "\n". The result from terminal execution has a trailing "\r\n".
Expected
Both outputs have the correct trailing "\r\n".
Addendum
run GitPython cmd with option "with_extended_output" -> same result
run GitPython cmd with option "stdout_as_string" -> same result (but in binary format)
crosscheck: run "git show" via subprocess.popen -> output has correct "\r\n"
# commits = ... p = subprocess.Popen(["git", "show", f"{commits[0].hexsha}:{testfile}"], stdout=subprocess.PIPE) out, err = p.communicate() print(repr(out))
The text was updated successfully, but these errors were encountered:
Thanks a lot for the wonderful description of the issue and for spending the time that undoubtedly when into it.
It's likely that GitPython strips git output somewhere in its command execution machinery, and I wonder why it was added in the first place.
git
Sorry, something went wrong.
No branches or pull requests
The result of git.Git.show (...) misses newlines ("\n") at the end of a file.
Reproduction
Observation
The string returned from show via GitPython has a trailing "\r", missing the "\n". The result from terminal execution has a trailing "\r\n".
Expected
Both outputs have the correct trailing "\r\n".
Addendum
run GitPython cmd with option "with_extended_output" -> same result
run GitPython cmd with option "stdout_as_string" -> same result (but in binary format)
crosscheck: run "git show" via subprocess.popen -> output has correct "\r\n"
The text was updated successfully, but these errors were encountered: