Skip to content

validate-family.py: while .gitmodules is unmerged, member-gitlink-removal-staged prints git checkout HEAD -- .gitmodules "as the index holds none", and that line resolves the merge to HEAD's side, dropping the other side's stage and overwriting a hand resolution on disk #1254

Open

Description

@brettheap

Problem

templates/family-root/scripts/validate-family.py's member-gitlink-removal-staged finding (a gitlink whose removal is staged and not committed) prints two lines where the work tree's .gitmodules is gone, or does not give the member's section: git reset -q -- <path>, and a put-back of the file the member's section is restored from. The put-back comes from _gitmodules_put_back, which resolves :.gitmodules with git rev-parse --verify --quiet and, finding no entry at stage 0, falls to HEAD:.gitmodules: git checkout HEAD -- .gitmodules, with the words "from HEAD's, as the index holds none" (GITMODULES_SOURCES).

While a merge leaves .gitmodules unmerged, the index does hold the file, at conflict stages 1 to 3 and none at stage 0, so the words are wrong, and the line does more than put a file back:

This is older than #1227 and unchanged by it: main's script prints the same text and the same lines in each state below (measured). #1227's Limits listed the state as not measured; its review (rv1227c, P4, NIT 1) measured it.

Evidence

rv1227c's probe test_p4_* (scratch file work/rv1227c/probes/test_rv1227c_probe.py in lane 5's folder, never committed), re-run at #1227's fix-round head 2d56c1906 on git 2.43.0 and on 2.47.1 (the same outcome on both), offline (run10.sh: stub gh, GIT_SSH_COMMAND=false, GIT_CONFIG_GLOBAL=/dev/null); logs in work/n1150g/out/head243/p4-*.log and out/head247/p4-*.log. The state: HEAD's .gitmodules clean, then the file held at conflict stages 1 to 3 (stage 3 giving IRSS branch = theirs) by git update-index --index-info, then git rm --cached -- members/IRRS (exit 0). Three forms of the work tree's file:

  1. Deleted. The gate (all three modes, exit 1) prints git reset -q -- members/IRRS and git checkout HEAD -- .gitmodules. Typed in order, both exit 0. After: git ls-files -s -- .gitmodules holds one entry at stage 0 (HEAD's blob 4a021eaf1), stages 1 to 3 gone; git status --porcelain and git diff HEAD -- .gitmodules are empty; the gate is family ok. The merge is resolved to HEAD's side and stage 3 is dropped unread.
  2. On disk, a hand resolution that drops IRRS's section (as a plain git rm of the submodule would have left it). The same two lines are printed. The git checkout HEAD line overwrites the file: branch = resolved-by-hand is gone from the work tree, HEAD's blob is at stage 0, git status is clean.
  3. On disk, a hand resolution that still gives the path. Only git reset -q -- members/IRRS is printed. .gitmodules stays at stages 1 to 3 (UU); the gate says family ok after it, while git's own submodule commands still read no file.

Main's script (blob 172647b3e) prints the same findings and lines in all three (== gate MAIN-SCRIPT in the same logs, compared with the head's: identical findings and lines, exit 1).

Suggested fix

In _gitmodules_put_back (or in _file_put_back, which every put-back goes through), ask _gitmodules_unmerged(root) first, as _sections_as_git_reads does, and print no git checkout line while it is true. In its place the finding says what _value_not_here says for the same state: git reads no .gitmodules while a merge leaves it unmerged, so resolve the merge in .gitmodules by hand, keeping the member's section, then stage it (git add -- .gitmodules); the git reset -q -- <path> line stays. Form 3, where the person has resolved the file by hand, then needs only the reset line and the stage line.

_file_put_back and _gitmodules_put_back have many callers (the value check, _check_gitmodules_paths, _check_gitmodules_named, _move_section for the wrong-case move, _gitlink_put_back, _plain_rm_said for the hand mount, _check_gitlinks_registered, and the staged removal's _check_removals_staged through _section_back). #1227 guards the value check, the path checks and the init stop; each of the others should be measured in the unmerged state before the fix is called complete.

Verify

  • A row for each of the three forms above: the printed lines typed in order; no printed line resolves the merge (.gitmodules is still at stages 1 to 3 after the lines, and a hand resolution on disk is untouched); the text says to resolve the merge by hand; and once the person resolves it and stages the file, the gate passes in every mode (ends_well), on git 2.43.0 and 2.47.1.
  • Each row fails on main's script.
  • tests/test_family_gitmodules_values.py, tests/test_validate_family_index_gitmodules.py, tests/test_validate_family_index_value_unmerged.py, tests/test_validate_family_remedies_typed.py and tests/test_family_holder_remedies_compose.py pass unchanged where no merge leaves .gitmodules unmerged.
  • tests/test_path_guard_hygiene.py, tests/test_repo_hygiene.py, tests/test_agents_md_codes.py, tests/test_cli_reference.py and tests/test_pinned_copy_text.py pass.

Found by rv1227c's NIT 1 on #1227 (issuecomment-6722728204), probe P4.

Lane: openreposhape-5 (openRepoShape-5)

Activity

  1. brettheap commented on Nov 8, 2026

    @brettheap
    ContributorAuthor

    (lane openRepoShape-5, 2026-11-08T15:53:02Z) A correction to this issue's "Suggested fix", from #1227's delta review: rv1227d's NIT 2, #1227 issuecomment-6723609032.

    Lane: openreposhape-5 (openRepoShape-5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions