Skip to content

fix(git): parse submodule paths that contain spaces - #35012

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-submodule-path-identity-fix
Oct 30, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-submodule-path-identity-fix

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

Problem

listSubmodulePaths parsed git config --file .gitmodules --get-regexp output by splitting each line at its first space. A submodule whose name contains a space (for example [submodule "my lib"]) produces the key submodule.my lib.path, so the parser returned lib.path my lib instead of the path. Diff reads for files inside that submodule were then routed to the parent repository, which showed the whole working file as added with an empty original side. The old .trim() also dropped leading or trailing spaces from quoted paths.

Fix

  • Read .gitmodules with git config -z, which prints each entry as key\nvalue\0, and iterate records with the existing iterateNulDelimitedFields.
  • Split each record at its first newline. Subsection names can contain spaces but not newlines, so the value keeps its exact bytes. Valueless keys (no newline) are skipped as before, and trailing-slash normalization is unchanged.
  • Pass captureWslLoginShellOutput: true so a WSL login-shell banner cannot be prepended to the first record (the same pattern as discard-changes.ts and remote-rebase.ts).

The return type (string[]), cache behavior, and wire contracts are unchanged. When there is no .gitmodules (including folder workspaces), the command fails and the existing catch still returns [].

Tests

  • One new mocked regression in status-submodule.test.ts: reads submodule names and paths that contain spaces. It fails on the old parser, which returns lib.path my lib.
  • Existing .gitmodules mocks in status-submodule.test.ts, status-submodule-path-cache.test.ts, and repos-local-clone-lifecycle.test.ts are updated to the -z output format.
  • Focused suites (those three files): 56 tests pass.

Read .gitmodules with config -z so a submodule name or path containing a
space (the default when 'git submodule add' targets a spaced path) keeps
its real path instead of being split at the first space.
@OrcaWin
OrcaWin force-pushed the OrcaWin/git-submodule-path-identity-fix branch from 8e55726 to ce1365d Compare October 30, 2026 10:32
@OrcaWin OrcaWin changed the title fix(git): preserve submodule config path identity fix(git): parse submodule paths that contain spaces Oct 30, 2026
@OrcaWin
OrcaWin marked this pull request as ready for review October 30, 2026 10:45
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 48facc1e-ca69-42b7-982f-00a7c32df1b7
Commits

Reviewing files that changed from the base of the PR and between a903985 and ce1365d.

Files selected for processing: 4
  • src/main/git/source-control/submodule-paths.ts
  • src/main/git/status-submodule-path-cache.test.ts
  • src/main/git/status-submodule.test.ts
  • src/main/ipc/repos-local-clone-lifecycle.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

listSubmodulePaths now requests NUL-delimited .gitmodules output and parses records containing a newline. It removes trailing slashes and excludes empty paths. The command also enables WSL login-shell output capture. Related tests now use NUL-terminated fixtures, and one test covers submodule names and paths containing spaces.

Priority: Normal

Merge Risk: Minimal · up to ce136

The parser correctly preserves spaced submodule paths and safely handles WSL output; no merge-blocking risk is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the problem, fix, affected behavior, and focused test results. It does not follow the repository template and omits the required linked issue, visual proof or an explicit N/A,… Update the description to include the template sections. Add an actual linked issue after “Fixes #”, state “N/A” with a reason for visual proof, document manual and platform testing, complete the AI disclosure when applicable, address revie…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: fixing parsing for submodule paths that contain spaces.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 4 files.

Full details: Description check

Explanation

The description explains the problem, fix, affected behavior, and focused test results. It does not follow the repository template and omits the required linked issue, visual proof or an explicit N/A, testing checklist details, AI disclosure, review notes, and final checklist.

Resolution

Update the description to include the template sections. Add an actual linked issue after “Fixes #”, state “N/A” with a reason for visual proof, document manual and platform testing, complete the AI disclosure when applicable, address review notes, and complete the checklist.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit cead2e2 into main Oct 30, 2026
71 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/git-submodule-path-identity-fix branch October 30, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant