Title: Using GitPython inside a pre-commit hook breaks (GIT_AUTHOR_DATE breaks) · Issue #963 · gitpython-developers/GitPython · GitHub
Open Graph Title: Using GitPython inside a pre-commit hook breaks (GIT_AUTHOR_DATE breaks) · Issue #963 · gitpython-developers/GitPython
X Title: Using GitPython inside a pre-commit hook breaks (GIT_AUTHOR_DATE breaks) · Issue #963 · gitpython-developers/GitPython
Description: I suspect the culprit of the crash is the GIT_AUTHOR_DATE. If I remove this before starting my script it works. I already pass expand_vars=False, but that isn't passed far enough down to make a differance. My current workaround is to nul...
Open Graph Description: I suspect the culprit of the crash is the GIT_AUTHOR_DATE. If I remove this before starting my script it works. I already pass expand_vars=False, but that isn't passed far enough down to make a dif...
X Description: I suspect the culprit of the crash is the GIT_AUTHOR_DATE. If I remove this before starting my script it works. I already pass expand_vars=False, but that isn't passed far enough down to make a...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/963
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using GitPython inside a pre-commit hook breaks (GIT_AUTHOR_DATE breaks)","articleBody":"I suspect the culprit of the crash is the GIT_AUTHOR_DATE. If I remove this before starting my script it works. I already pass `expand_vars=False`, but that isn't passed far enough down to make a differance.\r\n\r\nMy current workaround is to nulke the enviroment variables when invoking my script by using `env -i \u003cscript\u003e` from the commit hook.\r\n\r\nMy ideal solution would be a flag to disable the copy of the os environ on [git/cmd.py:699](https://github.com/gitpython-developers/GitPython/blob/master/git/cmd.py#L699). This will not only eliminate this issue, but also any potential other interferance (think GIT_DIR and friends).\r\n\r\nReplicate via:\r\n\r\n``` bash\r\nexport GIT_INDEX_FILE='.git/index'\r\nexport GIT_AUTHOR_DATE='@1574863356 +0100'\r\nexport GIT_EXEC_PATH='/usr/lib/git-core'\r\nexport GIT_AUTHOR_EMAIL='admin@dries007.net'\r\nexport GIT_PREFIX=''\r\nexport GIT_AUTHOR_NAME='Dries'\r\n\r\npython3\r\n```\r\n\r\n```python\r\nimport tempfile\r\n\r\nimport git\r\n\r\n\r\ndef main():\r\n with tempfile.TemporaryDirectory() as folder:\r\n repo = git.Repo.init(folder, expand_vars=False)\r\n repo.index.commit(\"Init test repo with empty commit.\")\r\n repo.head.reference = repo.create_head(\"master\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\nThanks,\r\nDries","author":{"url":"https://github.com/dries007","@type":"Person","name":"dries007"},"datePublished":"2019-11-27T14:23:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/963/GitPython/issues/963"}
| 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:7f11e8e5-0eb3-22b9-da36-d21146ffc593 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E958:CD10D:29062CB:35922CD:696B68F4 |
| html-safe-nonce | 105ab92ea3d248e522d7e2047cc69bb6bd17b962907cae597846e0968aa87a32 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTU4OkNEMTBEOjI5MDYyQ0I6MzU5MjJDRDo2OTZCNjhGNCIsInZpc2l0b3JfaWQiOiI4MjYzOTkyNDYyMTcwNzkwMjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 249705e07585e3437b6603da5cd164002fcd883eaed530e75c5f49c60099e6ff |
| hovercard-subject-tag | issue:529377961 |
| 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/963/issue_layout |
| twitter:image | https://opengraph.githubassets.com/31469a49204254e55b442594940da48a5ecf0b60dc97dfe63f79cb2629f8dedf/gitpython-developers/GitPython/issues/963 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/31469a49204254e55b442594940da48a5ecf0b60dc97dfe63f79cb2629f8dedf/gitpython-developers/GitPython/issues/963 |
| og:image:alt | I suspect the culprit of the crash is the GIT_AUTHOR_DATE. If I remove this before starting my script it works. I already pass expand_vars=False, but that isn't passed far enough down to make a dif... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dries007 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width