Title: git show result misses newline at end of diff · Issue #1377 · gitpython-developers/GitPython · GitHub
Open Graph Title: git show result misses newline at end of diff · Issue #1377 · gitpython-developers/GitPython
X Title: git show result misses newline at end of diff · Issue #1377 · gitpython-developers/GitPython
Description: The result of git.Git.show (...) misses newlines ("\n") at the end of a file. Reproduction setup git repo / use existing add empty textfile "foo.txt", commit file modify file by inserting string "foo\r\n", commit changes run git cmd "sho...
Open Graph Description: The result of git.Git.show (...) misses newlines ("\n") at the end of a file. Reproduction setup git repo / use existing add empty textfile "foo.txt", commit file modify file by inserting string "f...
X Description: The result of git.Git.show (...) misses newlines ("\n") at the end of a file. Reproduction setup git repo / use existing add empty textfile "foo.txt", commit file modify file by...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1377
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"git show result misses newline at end of diff","articleBody":"The result of git.Git.show (...) misses newlines (\"\\n\") at the end of a file.\r\n\r\n**Reproduction**\r\n\r\n1) setup git repo / use existing\r\n2) add empty textfile \"foo.txt\", commit file\r\n3) modify file by inserting string \"foo\\r\\n\", commit changes\r\n4) run git cmd \"show [commit sha]:foo.txt\"\r\n5) ... via GitPython, example:\r\n \r\n ```\r\n # commits = ...\r\n repo.git.show(f\"{commits[0].hexsha}:{testfile}\")\r\n ```\r\n6) ... from Git terminal, pipe through cat etc. to see control characters, example: \r\n\r\n ```\r\n git show 74e70e7:foo.txt | cat -vet | less\r\n ```\r\n\r\n**Observation**\r\n\r\nThe string returned from show via GitPython has a trailing \"\\r\", missing the \"\\n\". The result from terminal execution has a trailing \"\\r\\n\".\r\n\r\n\r\n**Expected**\r\n\r\nBoth outputs have the correct trailing \"\\r\\n\".\r\n\r\n\r\n**Addendum**\r\n\r\n- run GitPython cmd with option \"with_extended_output\" -\u003e same result\r\n- run GitPython cmd with option \"stdout_as_string\" -\u003e same result (but in binary format)\r\n- crosscheck: run \"git show\" via subprocess.popen -\u003e output has correct \"\\r\\n\"\r\n\r\n ```\r\n # commits = ...\r\n p = subprocess.Popen([\"git\", \"show\", f\"{commits[0].hexsha}:{testfile}\"], stdout=subprocess.PIPE)\r\n out, err = p.communicate()\r\n print(repr(out))\r\n ```\r\n","author":{"url":"https://github.com/markhh80","@type":"Person","name":"markhh80"},"datePublished":"2021-11-12T14:03:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/1377/GitPython/issues/1377"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cefaff82-af83-e644-73ef-693ee2451259 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E75A:2E3348:A3623C:E2C778:6968D941 |
| html-safe-nonce | 4734071e0c05f78388c24b211c56d47e1d74588023b73f5d6dc6dd974163b75f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzVBOjJFMzM0ODpBMzYyM0M6RTJDNzc4OjY5NjhEOTQxIiwidmlzaXRvcl9pZCI6IjUxMTk1NTE0MTE3MjgyMTAyNDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b89c28128734a35e6c10986f824b0df1e513da3e195e25c227914cc5e2a690a9 |
| hovercard-subject-tag | issue:1051999097 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1377/issue_layout |
| twitter:image | https://opengraph.githubassets.com/34cd22832a851c9991df969606015ed019aa3f007c4dbb5b1474bd51350e8f66/gitpython-developers/GitPython/issues/1377 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/34cd22832a851c9991df969606015ed019aa3f007c4dbb5b1474bd51350e8f66/gitpython-developers/GitPython/issues/1377 |
| og:image:alt | The result of git.Git.show (...) misses newlines ("\n") at the end of a file. Reproduction setup git repo / use existing add empty textfile "foo.txt", commit file modify file by inserting string "f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markhh80 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width