Title: Git, GitDB, and GitCmdObjectDB give different results when counting objects. · Issue #765 · gitpython-developers/GitPython · GitHub
Open Graph Title: Git, GitDB, and GitCmdObjectDB give different results when counting objects. · Issue #765 · gitpython-developers/GitPython
X Title: Git, GitDB, and GitCmdObjectDB give different results when counting objects. · Issue #765 · gitpython-developers/GitPython
Description: Use git to count the objects in a repo: $ git rev-list --objects --all | wc -l 6990030 $ git rev-list --objects --all | sort | uniq | wc -l 6990030 Parse the output from git rev-list --objects --all, fetch each object with name_to_object...
Open Graph Description: Use git to count the objects in a repo: $ git rev-list --objects --all | wc -l 6990030 $ git rev-list --objects --all | sort | uniq | wc -l 6990030 Parse the output from git rev-list --objects --al...
X Description: Use git to count the objects in a repo: $ git rev-list --objects --all | wc -l 6990030 $ git rev-list --objects --all | sort | uniq | wc -l 6990030 Parse the output from git rev-list --objects --al...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/765
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Git, GitDB, and GitCmdObjectDB give different results when counting objects.","articleBody":"1. Use git to count the objects in a repo:\r\n```\r\n$ git rev-list --objects --all | wc -l\r\n6990030\r\n$ git rev-list --objects --all | sort | uniq | wc -l\r\n6990030\r\n```\r\n\r\n2. Parse the output from `git rev-list --objects --all`, fetch each object with name_to_object, and count each type:\r\n```\r\nCommits: 909667, Tags: 2469, Trees: 4178263, Blobs: 1899631\r\n```\r\n\r\n3. Query what is ostensibly the same information using git-python:\r\n```\r\nimport argparse\r\nimport pathlib\r\n\r\nimport git\r\n\r\ndef log(testname, a, b):\r\n print(testname, ':', a, b)\r\n\r\ndef main():\r\n\r\n parser = argparse.ArgumentParser(description='Git x ref.')\r\n parser.add_argument('repository', metavar='repository', type=pathlib.Path,\r\n help='Path to Git repository.')\r\n\r\n args = parser.parse_args()\r\n\r\n repos = [\r\n git.Repo(str(args.repository), odbt=git.GitCmdObjectDB),\r\n git.Repo(str(args.repository), odbt=git.GitDB)\r\n ]\r\n\r\n log('size()', *[r.odb.size() for r in repos])\r\n log('len(sha_iter())', *[sum(1 for x in r.odb.sha_iter()) for r in repos])\r\n log('len(iter_trees())', *[sum(1 for x in r.iter_trees()) for r in repos])\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n```\r\n\r\nResult:\r\n\r\n```\r\nsize() : 3839 8268978\r\nlen(sha_iter()) : 3839 8268978\r\nlen(iter_trees()) : 568851 568851\r\n```\r\nSo:\r\n\r\nGit thinks there are 6,990,030 objects in the database.\r\nGitDB thinks there are 8,268,978.\r\nGitCmdObjectDB thinks there are 3,839.\r\n\r\nGit thinks there are 4,178,263 trees in the database.\r\nBoth GitDB and GitCmdObjectDB think there are 568,851.","author":{"url":"https://github.com/ali1234","@type":"Person","name":"ali1234"},"datePublished":"2018-06-05T19:14:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":54},"url":"https://github.com/765/GitPython/issues/765"}
| 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:252dd1a1-a6a0-60f8-6f56-f7427ad6eaaf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B77A:3E34BC:18B08AA:2292E33:696FD9DB |
| html-safe-nonce | 93371023dd48e73c09f9ce93d99ec8684af2c36410e52cfa8a5c38f5f930bec3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzdBOjNFMzRCQzoxOEIwOEFBOjIyOTJFMzM6Njk2RkQ5REIiLCJ2aXNpdG9yX2lkIjoiNjYwNzIzMTE4ODYwMDg3MTM4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 351b18e33b17de0550031f4237a907ba87bd74de428190b09a2b532acb67b92c |
| hovercard-subject-tag | issue:329589041 |
| 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/765/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f30a4f435e2e722fda0b6faa0308da83a83c9a6f60f8744b162d09c390a3e3ff/gitpython-developers/GitPython/issues/765 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f30a4f435e2e722fda0b6faa0308da83a83c9a6f60f8744b162d09c390a3e3ff/gitpython-developers/GitPython/issues/765 |
| og:image:alt | Use git to count the objects in a repo: $ git rev-list --objects --all | wc -l 6990030 $ git rev-list --objects --all | sort | uniq | wc -l 6990030 Parse the output from git rev-list --objects --al... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ali1234 |
| hostname | github.com |
| expected-hostname | github.com |
| None | a5d30ba41f7d9acded2fd135aa830ac2f5c7e52dca0e776e658d37eaf9dfb033 |
| 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 | 2f945b7bb88421600e89dfefbb1548ad0a44781a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width