Repository navigation
git_mf: Add --subs to merge submodules before the superproject - #142
Merged
Merged
Conversation
Merging one machine branch into another in boku conflicted on the dotfiles and jiyuu pointers, because each machine records its own submodule heads. --subs runs git_mf inside each initialized submodule first, commits the moved pointers, then merges the superproject; git fast-forwards each pointer that already contains the other side's. Changes besides submodule pointers, or a submodule that needs judgment, stop the run before the superproject is touched. Refs Unique-Divine/boku#201.
Unique-Divine
force-pushed
the
ud/git-mf-submodules
branch
from
November 15, 2026 22:26
294a515 to
7d58781
Compare
Dry-run each submodule and predict the superproject merge outside submodule pointers before any submodule moves. Refuse staged changes, route the dirty refusal through --agent, read .gitmodules NUL-separated, pass --subs, --agent, and --json to child runs, and make --dry-run report the --subs plan without planning against stale pointers. Found by an independent Codex review.
The preflight now runs git_mf TARGET --dry-run --subs, so every repository gets the normal checks (branch, detached HEAD, divergence, fetch failures, merge-tree errors) before anything changes. In --subs plans, pointer-only conflicts count as a merge and unstaged pointers do not count as dirty, matching what a real run does. With --agent, a failed preflight continues so each level can hand its refusal to the agent. Found by an independent Codex review.
--subs refuses on TARGET itself or a detached HEAD, where committing pointers would cause divergence. A failed preflight always stops, naming the repository to fix with --agent. A pointer-only conflict counts as a fast-forward only when the submodule's origin/TARGET contains the incoming pointer. Found by an independent Codex review.
Validate each incoming pointer against the submodule's origin/TARGET whatever the first plan predicts, so a fast-forward plan cannot turn into a pointer conflict after the pointer commit. The branch rule applies only to repositories with submodules. Found by an independent Codex review.
…e targets like the planner Found by an independent Codex review.
The planner does not model --ff-only, so a submodule needing a merge commit would pass the preflight and fail during apply. Found by an independent Codex review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of boku#201. On homebox,
git_mf ud/mainin boku stopped withmerge-conflict: dotfiles jiyuu. Each machine branch records its own machine's submodule heads, so merging one into the other always conflicts on the pointers.Changes
git_mf TARGET --subs(help text inbin/git_mf):git_mf TARGETinside each initialized submodule, passing--dry-run,--agent, and merge flags through. The first submodule that exits non-zero stops the run, and the superproject is left as it was.Fast-forwarding submodule sub.Usage on homebox:
git_mf ud/main --subsin~/boku.Verification
bun test bin/git_mf.test.ts: 48 pass, including 4 new scenarios built from a real superproject and submodule pair:--subsmerges both levels and leaves a clean tree, with the pointer at the submodule head containing both branches.merge-conflict: sub(exit 3).shellcheck -xadds no new warnings.