Title: Exception suggestion: raise when making a Commit with non-commit binsha · Issue #2254 · gitpython-developers/GitPython · GitHub
Open Graph Title: Exception suggestion: raise when making a Commit with non-commit binsha · Issue #2254 · gitpython-developers/GitPython
X Title: Exception suggestion: raise when making a Commit with non-commit binsha · Issue #2254 · gitpython-developers/GitPython
Description: Consider the following code snippet: import git repo = git.Repo('GitPython') tag = repo.rev_parse('3.1.62') commit = git.Commit(repo, tag.binsha) index_file = git.IndexFile.new(repo, commit.tree) If GitPython is a repo in the CWD, then u...
Open Graph Description: Consider the following code snippet: import git repo = git.Repo('GitPython') tag = repo.rev_parse('3.1.62') commit = git.Commit(repo, tag.binsha) index_file = git.IndexFile.new(repo, commit.tree) I...
X Description: Consider the following code snippet: import git repo = git.Repo('GitPython') tag = repo.rev_parse('3.1.62') commit = git.Commit(repo, tag.binsha) index_file = git.IndexFile.new(repo...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2254
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exception suggestion: raise when making a Commit with non-commit binsha","articleBody":"Consider the following code snippet:\n\n```Python\nimport git\nrepo = git.Repo('GitPython')\ntag = repo.rev_parse('3.1.62')\ncommit = git.Commit(repo, tag.binsha)\nindex_file = git.IndexFile.new(repo, commit.tree)\n```\n\nIf `GitPython` is a repo in the CWD, then upon running the above code, you will see a traceback like so:\n\n```text\nTraceback (most recent call last):\n File \"my_python_file.py\", line 5, in \u003cmodule>\n index_file = git.IndexFile.new(repo, commit.tree)\n File \"/usr/lib/python3.14/site-packages/git/index/base.py\", line 330, in new\n base_entries = aggressive_tree_merge(repo.odb, tree_sha_bytes)\n File \"/usr/lib/python3.14/site-packages/git/index/fun.py\", line 505, in aggressive_tree_merge\n for entry in traverse_tree_recursive(odb, tree_shas[-1], \"\"):\n ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.14/site-packages/git/objects/fun.py\", line 271, in traverse_tree_recursive\n data = tree_entries_from_data(odb.stream(tree_sha).read())\n File \"/usr/lib/python3.14/site-packages/git/objects/fun.py\", line 111, in tree_entries_from_data\n while data[i] != 0:\n ~~~~^^^\nIndexError: index out of range\n\n```\n\nThis throws an out-of-bounds array index exception when trying to parse the tag's database stream as a tree, which *should* fail. However, the real user error occurred when trying to make a `Commit` object from a tag object's binsha: `commit = git.Commit(repo, tag.binsha)`. The `Commit` constructor should raise an Exception with a message to this effect. For example, \"Given sha value \u003cX> does not refer to a commit`. ","author":{"url":"https://github.com/jeffro256","@type":"Person","name":"jeffro256"},"datePublished":"2026-09-28T02:25:00Z","url":"https://github.com/gitpython-developers/GitPython/issues/2254"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:9bafc6cb-f546-5da8-b441-d1a5ac33bc4c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9B4:EDA7A:CBA59E:103A97C:6B0100BA |
| html-safe-nonce | 934b663e24bfaeed42f34a78ff118b40b26956bfdd52a9e8f373af7a4ed86573 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUI0OkVEQTdBOkNCQTU5RToxMDNBOTdDOjZCMDEwMEJBIiwidmlzaXRvcl9pZCI6IjcxNTUwNzY2ODY5NjEyNDYzOTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9bfb3ce1fec37a4df5d97ee1a5bb6c36403f331039d937a0de0ecd0485ceaf27 |
| hovercard-subject-tag | issue:5608420567 |
| 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/2254/issue_layout |
| twitter:image | https://opengraph.githubassets.com/59705e56d467e2a921d3026852d89f622f588fd28b3433c62707c84e7f3a26e9/gitpython-developers/GitPython/issues/2254 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/59705e56d467e2a921d3026852d89f622f588fd28b3433c62707c84e7f3a26e9/gitpython-developers/GitPython/issues/2254 |
| og:image:alt | Consider the following code snippet: import git repo = git.Repo('GitPython') tag = repo.rev_parse('3.1.62') commit = git.Commit(repo, tag.binsha) index_file = git.IndexFile.new(repo, commit.tree) I... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jeffro256 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width