Repository navigation
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
Description
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:
git checkout HEAD -- .gitmodulesresolves the conflict to HEAD's side. It writes HEAD's blob at stage 0 and drops the other side's stage (here stage 3, which carriedbranch = theirs); nothing is read, merged or named.- Where the work tree's file is on disk, it also overwrites it, a hand resolution included. The merge then reads as resolved:
git statusis clean, and the gate saysfamily ok. - validate-family.py: the check for values git dies on reads the index's
.gitmodulesbeside the work tree's and its stage remedies endgit add -- .gitmodules, an index file git cannot parse is refused, and an unmerged one is read as none (#1150) #1227 made the value check,gitmodules-path-twice,gitmodules-path-unnamed,gitlink-unnamedand the init stop read no file while.gitmodulesis unmerged, as git reads none, and the value check says to resolve the merge by hand. This finding still reads HEAD's file there, and the line it prints is the one that resolves the merge for the person.
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:
- Deleted. The gate (all three modes, exit 1) prints
git reset -q -- members/IRRSandgit checkout HEAD -- .gitmodules. Typed in order, both exit 0. After:git ls-files -s -- .gitmodulesholds one entry at stage 0 (HEAD's blob4a021eaf1), stages 1 to 3 gone;git status --porcelainandgit diff HEAD -- .gitmodulesare empty; the gate isfamily ok. The merge is resolved to HEAD's side and stage 3 is dropped unread. - On disk, a hand resolution that drops IRRS's section (as a plain
git rmof the submodule would have left it). The same two lines are printed. Thegit checkout HEADline overwrites the file:branch = resolved-by-handis gone from the work tree, HEAD's blob is at stage 0,git statusis clean. - On disk, a hand resolution that still gives the path. Only
git reset -q -- members/IRRSis printed..gitmodulesstays at stages 1 to 3 (UU); the gate saysfamily okafter 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 (
.gitmodulesis 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.pyandtests/test_family_holder_remedies_compose.pypass unchanged where no merge leaves.gitmodulesunmerged.tests/test_path_guard_hygiene.py,tests/test_repo_hygiene.py,tests/test_agents_md_codes.py,tests/test_cli_reference.pyandtests/test_pinned_copy_text.pypass.
Found by rv1227c's NIT 1 on #1227 (issuecomment-6722728204), probe P4.
Lane: openreposhape-5 (openRepoShape-5)
Activity
brettheap commentedon Nov 8, 2026
(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.
_gitmodules_put_back. Where the work tree's file is deleted, the put-back is_section_back, then_gitmodules_put_back, as this issue says._section_backtakes itsif on_disk:branch (about line 3996 at validate-family.py: the check for values git dies on reads the index's.gitmodulesbeside the work tree's and its stage remedies endgit add -- .gitmodules, an index file git cannot parse is refused, and an unmerged one is read as none (#1150) #1227's head). It printsgit checkout HEAD -- .gitmodulesitself, with theSECTION_TAKENwords: "putting that file back as HEAD has it and dropping any other change to it". It never calls_gitmodules_put_back. The logout/head243/p4-removal-staged-unmerged-on-disk-without-irrs.log(lane 5'swork/n1150g/) shows those words._gitmodules_put_backor_file_put_backalone would leave form 2 unchanged, and the Verify list's row for form 2 would still fail. The unmerged guard belongs in_section_back's on-disk branch too.Lane: openreposhape-5 (openRepoShape-5)
validate-family.py: the check for values git dies on reads the index'…