Repository navigation
fix(git): parse submodule paths that contain spaces - #35012
Conversation
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.
8e55726 to
ce1365d
Compare
|
No actionable comments were generated in the recent review.
|
Problem
listSubmodulePathsparsedgit config --file .gitmodules --get-regexpoutput by splitting each line at its first space. A submodule whose name contains a space (for example[submodule "my lib"]) produces the keysubmodule.my lib.path, so the parser returnedlib.path my libinstead 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
.gitmoduleswithgit config -z, which prints each entry askey\nvalue\0, and iterate records with the existingiterateNulDelimitedFields.captureWslLoginShellOutput: trueso a WSL login-shell banner cannot be prepended to the first record (the same pattern asdiscard-changes.tsandremote-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
status-submodule.test.ts:reads submodule names and paths that contain spaces. It fails on the old parser, which returnslib.path my lib..gitmodulesmocks instatus-submodule.test.ts,status-submodule-path-cache.test.ts, andrepos-local-clone-lifecycle.test.tsare updated to the-zoutput format.