Skip to content

park and status read a root's legs out of .gitmodules with git config -z, so a submodule name with a space no longer loses the leg and a valueless key is never a path - #15

Merged
brettheap merged 1 commit into
mainfrom
fix/legs-by-nul
Sep 11, 2026
Merged

brettheap merged 1 commit into
mainfrom
fix/legs-by-nul

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up noted in #12's review. Both commands enumerate a root's mounted legs from .gitmodules and split the plain git config --get-regexp output at its first space. A submodule whose NAME carries a space — [submodule "sp ace"] with path = spec — prints as submodule.sp ace.path spec, so the path came back as ace.path spec, a directory that does not exist, and the leg was silently left out: of park's not-carried report (an unpushed leg commit unreported) and of status's rows (a whole leg missing). A key with no value prints bare; status guarded it, park's .git test masked it.

With -z each entry is key<LF>value<NUL>, and a valueless key has no LF at all, so the split cannot be fooled either way:

$ git config --file .gitmodules -z --get-regexp '^submodule\..*\.path$' | tr '\0\n' '|~'
submodule.sp ace.path~spec|submodule.empty.path|
  • park's submodule_paths and status's declared_legs, both outside the shared resolver block (verified byte-identical across the three commands).
  • One test each side builds a root with a submodule named sp ace and a valueless key beside it: park must report the leg's unpushed commit, status must show exactly one leg row, and neither may print the mangled key. Suite 249 -> 251. bash -n and shellcheck unchanged.

Small enough that no review round was run.

🤖 Generated with Claude Code

Summary by Sourcery

Correct park and status submodule discovery so spaced names remain valid legs and valueless keys are excluded.

Bug Fixes:

  • Preserve submodule legs whose names contain spaces when park and status read root .gitmodules entries.
  • Ignore valueless .gitmodules keys instead of treating them as paths or phantom legs.

Tests:

  • Add regression coverage for spaced submodule names and valueless keys in both park and status.

… config -z`, so a submodule name with a space no longer loses the leg and a valueless key is never a path

The plain `git config --get-regexp` output was split at its first space. A
submodule whose NAME carries a space — `[submodule "sp ace"]` with `path =
spec` — prints as `submodule.sp ace.path spec`, so the path came back as
`ace.path spec`, a directory that does not exist, and the leg was silently
left out: of park's not-carried report (an unpushed leg commit unreported),
and of status's rows (a whole leg missing). A key with no value prints bare;
status guarded it, park's `.git` test masked it. With `-z` each entry is
`key<LF>value<NUL>` and a valueless key has no LF at all, so the split cannot
be fooled either way. Both functions sit outside the shared resolver block,
which is untouched.

One test each side builds a root with a submodule named `sp ace` and a
valueless key beside it: park must report the leg's unpushed commit, status
must show exactly one leg row, and neither may print the mangled key. Suite
249 -> 251.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 11:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Switches park and status to parse NUL-delimited .gitmodules configuration records, preventing spaced submodule names from producing mangled paths and preventing valueless keys from being treated as legs; adds focused regression tests for both behaviors.

File-Level Changes

Change Details Files
Read .gitmodules path entries with NUL-delimited git config -z output and reject valueless entries instead of splitting ambiguous plain output.
  • Update park's submodule path enumeration to split key/value records at the newline delimiter.
  • Update status's declared-leg enumeration with the same parsing logic.
  • Preserve paths when submodule names contain spaces and avoid treating bare keys as paths.
park
status
Add regression coverage for spaced submodule names and valueless .gitmodules keys in both commands.
  • Verify park reports an unpushed commit in a leg whose submodule name contains a space.
  • Verify status shows exactly one valid leg row and no phantom valueless-key leg.
  • Assert mangled keys and phantom-leg diagnostics are absent.
tests/test_park_resume_commands.py
tests/test_status_command.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes address the parsing issues and include regression coverage.

Pull request overview

This pull request fixes .gitmodules parsing in park and status for spaced submodule names and valueless keys.

Changes:

  • Use NUL-delimited Git config records for safe key/value parsing.
  • Add regression tests for both commands.
File summaries
File Summary
tests/test_status_command.py Tests correct leg enumeration and status output.
tests/test_park_resume_commands.py Tests spaced names and valueless keys in park.
status Corrects declared-leg enumeration.
park Corrects mounted-leg path extraction.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants