Title: Committing a path that switched between file and directory fails (e.g. symlink replaced by a folder) · Issue #1 · reemus-dev/subcommit · GitHub
Open Graph Title: Committing a path that switched between file and directory fails (e.g. symlink replaced by a folder) · Issue #1 · reemus-dev/subcommit
X Title: Committing a path that switched between file and directory fails (e.g. symlink replaced by a folder) · Issue #1 · reemus-dev/subcommit
Description: subcommit can't commit a path that switched between a file and a directory, in either direction. Git's raw error leaks out, and the only fallback is plain git rm --cached plus git add. Found when I replaced a committed symlink skills/cua...
Open Graph Description: subcommit can't commit a path that switched between a file and a directory, in either direction. Git's raw error leaks out, and the only fallback is plain git rm --cached plus git add. Found when I...
X Description: subcommit can't commit a path that switched between a file and a directory, in either direction. Git's raw error leaks out, and the only fallback is plain git rm --cached plus git add. Foun...
Opengraph URL: https://github.com/reemus-dev/subcommit/issues/1
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Committing a path that switched between file and directory fails (e.g. symlink replaced by a folder)","articleBody":"subcommit can't commit a path that switched between a file and a directory, in either direction. Git's raw error leaks out, and the only fallback is plain `git rm --cached` plus `git add`.\n\nFound when I replaced a committed symlink `skills/cua-driver` with a folder `skills/cua-driver/SKILL.md`. Symlinks are not required to reproduce it.\n\n## Reproduce\n\n```bash\ngit init -q r && cd r\necho f > p && git add p && git commit -qm init\nrm p && mkdir p && echo g > p/q\n\nsubcommit p/q -m t --yes\n# error: git update-index --add --cacheinfo 100644,\u003coid>,p/q: error: 'p/q' appears as both a file and as a directory\n# error: p/q: cannot add to the index - missing --add option?\n# fatal: git update-index: --cacheinfo cannot add p/q\n\nsubcommit p p/q -m t --yes\n# error: cannot commit a directory: p\n```\n\nThe reverse case (`p/q` committed, `p` is now a file) fails the same way:\n\n```bash\nsubcommit p -m t --yes # same \"appears as both a file and as a directory\"\nsubcommit p p/q -m t --yes # error: open .../p: not a directory\n```\n\n## Cause\n\n`complete.go` and `finalize.go` stage with `update-index --add --cacheinfo`. Git refuses to add `p/q` while the index still holds `p`, or the reverse, unless you pass `--replace`. With `--replace`, both cases stage correctly (`D p`, `A p/q`, and the reverse).\n\nSelecting the old path doesn't help either. The worktree now has the opposite type at that path, so the selection step rejects it (`cannot commit a directory`) or fails to stat it (`not a directory`).\n\n## Design question\n\n`--replace` silently drops the conflicting index entries, and those were not selected. That widens the commit beyond the selection, against the explicit-scope guarantee. Options:\n\n1. Stage with `--replace` only when the displaced paths are also selected. Accept the old path as a target for this case (a removed file or a removed directory), as the \"move includes both endpoints\" rule already does. Otherwise, fail with a diagnostic that names the displaced paths to add.\n2. Always use `--replace`, and list the displaced paths in the preview as included removals.\n\nOption 1 fits the scope guarantees better.\n","author":{"url":"https://github.com/realfresh","@type":"Person","name":"realfresh"},"datePublished":"2026-11-05T00:09:11Z","url":"https://github.com/reemus-dev/subcommit/issues/1"}
| 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:c4fad23d-06b8-bb92-caa1-f6821dbc640c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE4A:16A125:96095B:C815CB:6B00B5FB |
| html-safe-nonce | d16d2c5d88df574bbc481502fec9676c0092f6f6011f826df6177107f8bc6bc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTRBOjE2QTEyNTo5NjA5NUI6QzgxNUNCOjZCMDBCNUZCIiwidmlzaXRvcl9pZCI6IjIxNDc5NjY5NzUzNDk5Mjk0NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cbf3cda2afb2023f01239186c387523754125a7d90b73186ed80589d1427bb35 |
| hovercard-subject-tag | issue:6213886057 |
| 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/reemus-dev/subcommit/1/issue_layout |
| twitter:image | https://opengraph.githubassets.com/619bc21784cae61a578e1d478abc612e3fa70cbe25a5dec243432b8978b9c791/reemus-dev/subcommit/issues/1 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/619bc21784cae61a578e1d478abc612e3fa70cbe25a5dec243432b8978b9c791/reemus-dev/subcommit/issues/1 |
| og:image:alt | subcommit can't commit a path that switched between a file and a directory, in either direction. Git's raw error leaks out, and the only fallback is plain git rm --cached plus git add. Found when I... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | realfresh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d07c25977adfc5ff6acb0a962a9bc168c07afbda6fef765f9761c350c2ae4a2 |
| turbo-cache-control | no-preview |
| go-import | github.com/reemus-dev/subcommit git https://github.com/reemus-dev/subcommit.git |
| octolytics-dimension-user_id | 133128348 |
| octolytics-dimension-user_login | reemus-dev |
| octolytics-dimension-repository_id | 1354074441 |
| octolytics-dimension-repository_nwo | reemus-dev/subcommit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1354074441 |
| octolytics-dimension-repository_network_root_nwo | reemus-dev/subcommit |
| 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 | 5429cbfc6aca8c7b9a086a3c8f47400346f38cc9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width