René's URL Explorer Experiment


Title: `npm install git+file://` during hook install inside a submodule overwrites the submodule's index · Issue #3773 · pre-commit/pre-commit · GitHub

Open Graph Title: `npm install git+file://` during hook install inside a submodule overwrites the submodule's index · Issue #3773 · pre-commit/pre-commit

X Title: `npm install git+file://` during hook install inside a submodule overwrites the submodule's index · Issue #3773 · pre-commit/pre-commit

Description: search you tried in the issue tracker GIT_INDEX_FILE, GIT_DIR, no_git_env, submodule, "unable to read", "invalid object", git+file, npm git describe your issue Since 4.6.1, when a language: node hook environment is installed by git commi...

Open Graph Description: search you tried in the issue tracker GIT_INDEX_FILE, GIT_DIR, no_git_env, submodule, "unable to read", "invalid object", git+file, npm git describe your issue Since 4.6.1, when a language: node ho...

X Description: search you tried in the issue tracker GIT_INDEX_FILE, GIT_DIR, no_git_env, submodule, "unable to read", "invalid object", git+file, npm git describe your issue Since 4.6.1, when...

Opengraph URL: https://github.com/pre-commit/pre-commit/issues/3773

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`npm install git+file://` during hook install inside a submodule overwrites the submodule's index","articleBody":"### search you tried in the issue tracker\n\nGIT_INDEX_FILE, GIT_DIR, no_git_env, submodule, \"unable to read\", \"invalid object\", git+file, npm git\n\n### describe your issue\n\nSince 4.6.1, when a `language: node` hook environment is installed by `git commit` run inside a git submodule, the submodule's index is replaced with the index of the hook repository. The commit fails and whatever was staged is lost. 4.6.0 is not affected: the reproduction below passes on 4.6.0 and on ff8541f, and fails on b1cc920 (#3719), 4.6.1 and 4.6.2.\n\nInside a submodule, git runs the pre-commit hook with absolute `GIT_DIR` and `GIT_INDEX_FILE` (`\u003csuper>/.git/modules/\u003cname>` and `\u003csuper>/.git/modules/\u003cname>/index`). #3719 changed the install to `npm install ... git+file://\u003cstore clone>`, and npm clones and checks out that URL with git. That `git` inherits `GIT_INDEX_FILE`, so the checkout writes the hook repository's index to the submodule's index file. `store.py` already runs the initial clone of the hook repository with `no_git_env()`. The npm install does not.\n\nConfirm the issue on 4.6.2 using this Dockerfile:\n\n```dockerfile\nFROM python:3.13\n\nARG PRE_COMMIT=pre-commit==4.6.2\n\nRUN pip install \"${PRE_COMMIT}\"\nRUN git config --global user.name repro \\\n    && git config --global user.email repro@example.com \\\n    && git config --global protocol.file.allow always\n\nWORKDIR /repro\n\nCOPY \u003c\u003c'EOF' repro.sh\nset -eu\npre-commit --version\n\ngit init -q sub\ncd sub\n\ncat > .pre-commit-config.yaml \u003c\u003c'YAML'\nrepos:\n  - repo: https://github.com/rbubley/mirrors-prettier\n    rev: v3.6.2\n    hooks:\n      - id: prettier\nYAML\n\ngit add .pre-commit-config.yaml\ngit commit -q -m init\ncd ..\n\ngit init -q super\ncd super\n\ngit submodule -q add ../sub sub\ngit commit -q -m 'add submodule'\n\ncd sub\npre-commit install\n\necho '# hello' > README.md\ngit add README.md\ngit commit -m 'trigger install from inside a submodule' || true\n\necho '--- submodule index (expected: .pre-commit-config.yaml, README.md)'\ngit ls-files -s\ncat ~/.cache/pre-commit/pre-commit.log 2>/dev/null || true\nEOF\n\nCMD [\"bash\", \"repro.sh\"]\n```\n\n```bash\ndocker build -t pre-commit-submodule-repro .\ndocker run --rm pre-commit-submodule-repro\n```\n\noutput of `docker run` (the `pre-commit.log` it prints at the end is in the log field below):\n\n```\npre-commit 4.6.2\npre-commit installed at /repro/super/.git/modules/sub/hooks/pre-commit\n[INFO] Initializing environment for https://github.com/rbubley/mirrors-prettier.\n[INFO] Initializing environment for https://github.com/rbubley/mirrors-prettier:prettier@3.6.2.\n[INFO] Installing environment for https://github.com/rbubley/mirrors-prettier.\n[INFO] Once installed this environment will be reused.\n[INFO] This may take a few minutes...\nAn unexpected error has occurred: CalledProcessError: command: ('/usr/lib/git-core/git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z', '--diff-filter=ACMRTUXB')\nreturn code: 128\nstdout: (none)\nstderr:\n    fatal: unable to read 7192ee1c223039c8ac42c8871ec7f6f8faeedebd\nCheck the log at /root/.cache/pre-commit/pre-commit.log\n--- submodule index (expected: .pre-commit-config.yaml, README.md)\n100644 7192ee1c223039c8ac42c8871ec7f6f8faeedebd 0\t.github/workflows/main.yml\n100644 72e8ffc0db8aad71a934dd11e5968bd5109e54b4 0\t.npmignore\n100644 a7d109de0c111bd5b225d20183593b283ad80516 0\t.pre-commit-hooks.yaml\n100644 b72762837ea636398fece3c5651f664c2ee82ffb 0\t.version\n100644 d86d9ea06347dbd79c04079484155ea94fa2c3ed 0\tLICENSE\n100644 92a483e6ca5ae20de5bae985aa1215eb658c6498 0\tREADME.md\n100644 d4083c5b452e10dc41112eae1813d9d1631024b5 0\tpackage.json\n```\n\nThe submodule's index now holds the files of `mirrors-prettier`. `git read-tree HEAD` in the submodule recovers it.\n\nConfirm 4.6.0 is not affected:\n\n```bash\ndocker build --build-arg PRE_COMMIT=pre-commit==4.6.0 -t pre-commit-submodule-repro:4.6.0 .\ndocker run --rm pre-commit-submodule-repro:4.6.0\n```\n\nWorkaround: run `pre-commit install-hooks` from a shell before committing.\n\nThe closest related issues I found is #1379 which has the same `fatal: unable to read \u003csha>` after a fresh install; the cause was never found for this one.\n\n### pre-commit --version\n\npre-commit 4.6.2\n\n### .pre-commit-config.yaml\n\n```yaml\nrepos:\n  - repo: https://github.com/rbubley/mirrors-prettier\n    rev: v3.6.2\n    hooks:\n      - id: prettier\n```\n\n### ~/.cache/pre-commit/pre-commit.log (if present)\n\n### version information\n\n```\npre-commit version: 4.6.2\ngit --version: git version 2.47.3\nsys.version:\n    3.13.16 (main, Oct  6 2026, 04:43:07) [GCC 14.2.0]\nsys.executable: /usr/local/bin/python3.13\nos.name: posix\nsys.platform: linux\n```\n\n### error information\n\n```\nAn unexpected error has occurred: CalledProcessError: command: ('/usr/lib/git-core/git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z', '--diff-filter=ACMRTUXB')\nreturn code: 128\nstdout: (none)\nstderr:\n    fatal: unable to read 7192ee1c223039c8ac42c8871ec7f6f8faeedebd\n```\n\n```\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/error_handler.py\", line 73, in error_handler\n    yield\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/main.py\", line 401, in main\n    return hook_impl(\n        store,\n    ...\u003c5 lines>...\n        args=args.rest[1:],\n    )\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/commands/hook_impl.py\", line 275, in hook_impl\n    return retv | run(config, store, ns)\n                  ~~~^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/commands/run.py\", line 445, in run\n    return _run_hooks(config, hooks, skips, args)\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/commands/run.py\", line 291, in _run_hooks\n    _all_filenames(args), config['files'], config['exclude'],\n    ~~~~~~~~~~~~~~^^^^^^\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/commands/run.py\", line 271, in _all_filenames\n    return git.get_staged_files()\n           ~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/git.py\", line 137, in get_staged_files\n    cmd_output(\n    ~~~~~~~~~~^\n        'git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z',\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    ...\u003c2 lines>...\n        cwd=cwd,\n        ^^^^^^^^\n    )[1],\n    ^\n  File \"/usr/local/lib/python3.13/site-packages/pre_commit/util.py\", line 117, in cmd_output\n    returncode, stdout_b, stderr_b = cmd_output_b(*cmd, **kwargs)\n                                     ~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.13/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/lib/git-core/git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z', '--diff-filter=ACMRTUXB')\nreturn code: 128\nstdout: (none)\nstderr:\n    fatal: unable to read 7192ee1c223039c8ac42c8871ec7f6f8faeedebd\n```\n","author":{"url":"https://github.com/cbirkhold","@type":"Person","name":"cbirkhold"},"datePublished":"2026-10-09T06:31:00Z","url":"https://github.com/pre-commit/pre-commit/issues/3773"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5d88b691-b5b1-2680-7055-f7e39e7c5a27
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB3A0:4279A:2EA4E31:3EBFEE5:6B01F253
html-safe-nonce33011fe942beed6832b0ddb2a5b1edd43bd865ea8c5788f4b591b47e9319918c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0EwOjQyNzlBOjJFQTRFMzE6M0VCRkVFNTo2QjAxRjI1MyIsInZpc2l0b3JfaWQiOiI2NjM2NDUxNzA2NTY3NzgyOTk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca68b9a0d44f482c22b675e698c96d8c4fb2f3185f42d8c0ea9321209fb23478e
hovercard-subject-tagissue:5773890135
github-keyboard-shortcutsrepository,issues,commits,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit/3773/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7d0a1f707071a5d5508a6f6d2386cdc7e0f3a8253119eb24ac6365fa4e942f16/pre-commit/pre-commit/issues/3773
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7d0a1f707071a5d5508a6f6d2386cdc7e0f3a8253119eb24ac6365fa4e942f16/pre-commit/pre-commit/issues/3773
og:image:altsearch you tried in the issue tracker GIT_INDEX_FILE, GIT_DIR, no_git_env, submodule, "unable to read", "invalid object", git+file, npm git describe your issue Since 4.6.1, when a language: node ho...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecbirkhold
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git
octolytics-dimension-user_id6943086
octolytics-dimension-user_loginpre-commit
octolytics-dimension-repository_id17689377
octolytics-dimension-repository_nwopre-commit/pre-commit
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id17689377
octolytics-dimension-repository_network_root_nwopre-commit/pre-commit
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/pre-commit/pre-commit/issues/3773#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpre-commit%2Fpre-commit%2Fissues%2F3773
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpre-commit%2Fpre-commit%2Fissues%2F3773
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pre-commit%2Fpre-commit
Reloadhttps://github.com/pre-commit/pre-commit/issues/3773
Reloadhttps://github.com/pre-commit/pre-commit/issues/3773
Reloadhttps://github.com/pre-commit/pre-commit/issues/3773
pre-commithttps://github.com/pre-commit
pre-commithttps://github.com/pre-commit/pre-commit
Codehttps://github.com/pre-commit/pre-commit
Issues17 (17)https://github.com/pre-commit/pre-commit/issues
Pull requests8 (8)https://github.com/pre-commit/pre-commit/pulls
Actionshttps://github.com/pre-commit/pre-commit/actions
Security and qualityhttps://github.com/pre-commit/pre-commit/security
Insightshttps://github.com/pre-commit/pre-commit/insights
https://github.com/pre-commit/pre-commit
New issuehttps://github.com/login?return_to=https://github.com/pre-commit/pre-commit/issues/3773
New issuehttps://github.com/login?return_to=https://github.com/pre-commit/pre-commit/issues/3773
#3774https://github.com/pre-commit/pre-commit/pull/3774
npm install git+file:// during hook install inside a submodule overwrites the submodule's indexhttps://github.com/pre-commit/pre-commit/issues/3773#top
#3774https://github.com/pre-commit/pre-commit/pull/3774
https://github.com/cbirkhold
cbirkholdhttps://github.com/cbirkhold
on Oct 9, 2026https://github.com/pre-commit/pre-commit/issues/3773#issue-5773890135
ff8541fhttps://github.com/pre-commit/pre-commit/commit/ff8541f211c8be237a0efe442eaff5bda0e433e6
b1cc920https://github.com/pre-commit/pre-commit/commit/b1cc920ebb5ac01a86a32149dfa0644e496b44ec
#3719https://github.com/pre-commit/pre-commit/pull/3719
#3719https://github.com/pre-commit/pre-commit/pull/3719
#1379https://github.com/pre-commit/pre-commit/issues/1379
https://github.com/Tycorc
Tycorchttps://github.com/Tycorc
on Oct 11, 2026https://github.com/pre-commit/pre-commit/issues/3773#issuecomment-6108591208
#3774https://github.com/pre-commit/pre-commit/pull/3774
asottilehttps://github.com/asottile
completedhttps://github.com/pre-commit/pre-commit/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#3774https://github.com/pre-commit/pre-commit/pull/3774
on Oct 12, 2026https://github.com/pre-commit/pre-commit/issues/3773#event-33079560043
rlichtenwalterhttps://github.com/rlichtenwalter
on Oct 16, 2026https://github.com/pre-commit/pre-commit/issues/3773#event-33463405522
chore: Update pre-commit hookshttps://github.com/rlichtenwalter/kdtree/commit/177e0e7d3e38d68e800e389914d518db6a0c4621
177e0e7https://github.com/rlichtenwalter/kdtree/commit/177e0e7d3e38d68e800e389914d518db6a0c4621
chore: Update pre-commit hookshttps://github.com/rlichtenwalter/mRMR/commit/7502f4735efb67e370f7f17cd503c48f6884b513
7502f47https://github.com/rlichtenwalter/mRMR/commit/7502f4735efb67e370f7f17cd503c48f6884b513
chore: Update pre-commit hookshttps://github.com/rlichtenwalter/popc/commit/9b3e95aef674c1f585ee0d15f7de12de9b4dc054
9b3e95ahttps://github.com/rlichtenwalter/popc/commit/9b3e95aef674c1f585ee0d15f7de12de9b4dc054
chore: Update pre-commit hookshttps://github.com/rlichtenwalter/vcp/commit/134b5b87ccf90531bb983a5fcb762ae0674f2d2a
134b5b8https://github.com/rlichtenwalter/vcp/commit/134b5b87ccf90531bb983a5fcb762ae0674f2d2a
Sign up for freehttps://github.com/signup?return_to=https://github.com/pre-commit/pre-commit/issues/3773
Sign in to commenthttps://github.com/login?return_to=https://github.com/pre-commit/pre-commit/issues/3773
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.