Title: fails pulling hooks from sha1 repos with `init.defaultobjectformat=sha256`. · Issue #3434 · pre-commit/pre-commit · GitHub
Open Graph Title: fails pulling hooks from sha1 repos with `init.defaultobjectformat=sha256`. · Issue #3434 · pre-commit/pre-commit
X Title: fails pulling hooks from sha1 repos with `init.defaultobjectformat=sha256`. · Issue #3434 · pre-commit/pre-commit
Description: search you tried in the issue tracker sha256 describe your issue I have init.defaultobjectformat=sha256 configure globally to ensure I do not create any new repositories with sha1 anymore. If in a (local) sha256 repo which refers to a re...
Open Graph Description: search you tried in the issue tracker sha256 describe your issue I have init.defaultobjectformat=sha256 configure globally to ensure I do not create any new repositories with sha1 anymore. If in a ...
X Description: search you tried in the issue tracker sha256 describe your issue I have init.defaultobjectformat=sha256 configure globally to ensure I do not create any new repositories with sha1 anymore. If in a ...
Opengraph URL: https://github.com/pre-commit/pre-commit/issues/3434
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fails pulling hooks from sha1 repos with `init.defaultobjectformat=sha256`.","articleBody":"### search you tried in the issue tracker\n\nsha256\n\n### describe your issue\n\nI have `init.defaultobjectformat=sha256` configure globally to ensure I do not create any new repositories with sha1 anymore. If in a (local) sha256 repo which refers to [a remote sha1 repo](https://github.com/fsfe/reuse-tool) in its `.pre-commit-config.yaml` I run\n\n```sh\npre-commit run --all-files\n```\n\n, I get the following error:\n\n```\n[INFO] Initializing environment for https://github.com/fsfe/reuse-tool.\nAn unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')\nreturn code: 128\nstdout: (none)\nstderr:\n fatal: mismatched algorithms: client sha256; server sha1\nCheck the log at /home/mschilli87/.cache/pre-commit/pre-commit.log\n```\n\nTemporarily setting\n\n```sh\ngit config --global init.defaultObjectFormat sha1\n```\n\nenables `pre-commit run` to pass and successfully I can set\n\n\n```sh\ngit config --global init.defaultObjectFormat sha256\n```\n\nagain and it keeps working.\n\nI guess for some reason, instead of cloning the upstream sha1 repo locally via `git clone`, `pre-commit` for some reason initiates an empty repo via `git init`, adds the upstream repo as `origin` via `git remote add` and the tries to fetch the specified tag via `git fetch`.\n\nAnyhow, running a pre-commit hook on an existing repo based on an upstream one should not depend on config options specific to the creation of new local repos, so I consider this a bug.\n\n### pre-commit --version\n\npre-commit 4.2.0\n\n### .pre-commit-config.yaml\n\n```yaml\n# SPDX-FileCopyrightText: 2020 Free Software Foundation Europe e.V.\n# SPDX-License-Identifier: CC0-1.0\nrepos:\n - repo: https://github.com/fsfe/reuse-tool\n rev: v5.0.2\n hooks:\n - id: reuse\n```\n\n### ~/.cache/pre-commit/pre-commit.log (if present)\n\n### version information\n\n```\npre-commit version: 4.2.0\ngit --version: git version 2.49.0\nsys.version:\n 3.12.9 (main, Mar 4 2025, 22:48:41) [GCC 13.3.0]\nsys.executable: /usr/bin/python3.12\nos.name: posix\nsys.platform: linux\n```\n\n### error information\n\n```\nAn unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')\nreturn code: 128\nstdout: (none)\nstderr:\n fatal: mismatched algorithms: client sha256; server sha1\n```\n\n```\nTraceback (most recent call last):\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 207, in clone_strategy\n self._shallow_clone(ref, _git_cmd)\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 189, in _shallow_clone\n git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1')\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 204, in _git_cmd\n cmd_output_b('git', *args, cwd=directory, env=env)\n File \"/usr/lib/python3.12/site-packages/pre_commit/util.py\", line 111, in cmd_output_b\n raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)\npre_commit.util.CalledProcessError: command: ('/usr/bin/git', '-c', 'protocol.version=2', 'fetch', 'origin', 'v5.0.2', '--depth=1')\nreturn code: 128\nstdout: (none)\nstderr:\n fatal: mismatched algorithms: client sha256; server sha1\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/usr/lib/python3.12/site-packages/pre_commit/error_handler.py\", line 73, in error_handler\n yield\n File \"/usr/lib/python3.12/site-packages/pre_commit/main.py\", line 417, in main\n return run(args.config, store, args)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/commands/run.py\", line 425, in run\n for hook in all_hooks(config, store)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/repository.py\", line 233, in all_hooks\n return tuple(\n ^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/repository.py\", line 236, in \u003cgenexpr>\n for hook in _repository_hooks(repo, store, root_config)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/repository.py\", line 211, in _repository_hooks\n return _cloned_repository_hooks(repo_config, store, root_config)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/repository.py\", line 177, in _cloned_repository_hooks\n manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)\n ^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 211, in clone\n return self._new_repo(repo, ref, deps, clone_strategy)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 165, in _new_repo\n make_strategy(directory)\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 209, in clone_strategy\n self._complete_clone(ref, _git_cmd)\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 181, in _complete_clone\n git_cmd('fetch', 'origin', '--tags')\n File \"/usr/lib/python3.12/site-packages/pre_commit/store.py\", line 204, in _git_cmd\n cmd_output_b('git', *args, cwd=directory, env=env)\n File \"/usr/lib/python3.12/site-packages/pre_commit/util.py\", line 111, in cmd_output_b\n raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)\npre_commit.util.CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')\nreturn code: 128\nstdout: (none)\nstderr:\n fatal: mismatched algorithms: client sha256; server sha1\n```","author":{"url":"https://github.com/mschilli87","@type":"Person","name":"mschilli87"},"datePublished":"2025-03-24T11:07:38Z","url":"https://github.com/pre-commit/pre-commit/issues/3434"}
| 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:67ee1adf-eded-718e-f0ca-1d45c3cb80f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C4E0:7F906:17B4E86:1F36060:6B067243 |
| html-safe-nonce | 142405bda719b01dfbb0de9a8f8b59b0f1e86966645ab4805926f25e1540dd4c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEUwOjdGOTA2OjE3QjRFODY6MUYzNjA2MDo2QjA2NzI0MyIsInZpc2l0b3JfaWQiOiI1MjQzMTMyOTY2Nzc5Mzg0Mzg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8a2173e5cfcaa03210b6a6b337b40842afe216dd82db24045cdcb927e6121b12 |
| hovercard-subject-tag | issue:2942880008 |
| github-keyboard-shortcuts | repository,issues,commits,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/pre-commit/pre-commit/3434/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f7e351aaf3fb54ec86e226cc2eaa7117a3ab8f9417dc9c2bd65a17193218fdf/pre-commit/pre-commit/issues/3434 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f7e351aaf3fb54ec86e226cc2eaa7117a3ab8f9417dc9c2bd65a17193218fdf/pre-commit/pre-commit/issues/3434 |
| og:image:alt | search you tried in the issue tracker sha256 describe your issue I have init.defaultobjectformat=sha256 configure globally to ensure I do not create any new repositories with sha1 anymore. If in a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mschilli87 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17689377 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17689377 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit |
| 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 | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width