At least Git 2.38 (Q3 2022) provides more detailed help messages while merging submodules, especially in case of merge conflict.
See commit 565577e, commit 34ce504, commit a5834b7 (18 Aug 2022) by Elijah Newren (newren
).
See commit 4057523 (04 Aug 2022) by Calvin Wan (CalvinWan0101
).
(Merged by Junio C Hamano -- gitster
-- in commit df3c129, 25 Aug 2022)
submodule merge
: update conflict error message
Signed-off-by: Calvin Wan
When attempting to merge in a superproject with conflicting submodule pointers that cannot be fast-forwarded or trivially resolved, the merge fails and Git prints an error message that accurately describes the failure, but does not provide steps for the user to resolve the error.
Git is left in a conflicted state, which requires the user to:
- merge submodules or update submodules to an already existing commit that reflects the merge
- add submodules changes to the superproject
- finish merging superproject
These steps are non-obvious for newer submodule users to figure out based on the error message and neither git submodule status
(man) nor git status
(man) provide any useful pointers.
Update error message to provide steps to resolve submodule merge conflict.
Although the message is long, it also has the id of the submodule commit that needs to be merged, which could be useful information for the user.
Additionally, 5 merge failures that resulted in an early return have been updated to reflect the status of the merge.
- Null merge base (null o):
CONFLICT_SUBMODULE_NULL_MERGE_BASE
added
as a new conflict type and will print updated error message.
- Null merge side a (null a): BUG(). See discussion
- Null merge side b (null b): BUG(). See for discussion
- Submodule not checked out: added NEEDSWORK bit
- Submodule commits not present: added NEEDSWORK bit The errors with a NEEDSWORK bit deserve a more detailed explanation of how to resolve them.
See here for more context.
You now have a line of advice to resolve a merge conflict in a submodule.
The first argument is the submodulename, and the second argument is the abbreviated id of the commit that needs to be merged.
For example:
go to submodule (mysubmodule), and either merge commit abc1234
or update to an existing commit which has merged those changes
Also, new message:
Recursive merging with submodules currently only supports trivial cases.
Please manually handle the merging of each conflicted submodule.
This can be accomplished with the following steps:
sub1:
- come back to superproject and run:"
git add sub1
to record the above merge or update"
- resolve any other conflicts in the superproject
- commit the resulting index in the superproject
With Git 2.45 (Q2 2024), batch 4, when a merge conflicted at a submodule, merge-ort backend used to unconditionally give a lengthy message to suggest how to resolve it.
Now the message can be squelched as an advice message.
See commit b9e55be (26 Feb 2024) by Philippe Blain (phil-blain
).
(Merged by Junio C Hamano -- gitster
-- in commit 661f379, 05 Mar 2024)
merge-ort
: turn submodule conflict suggestions into an advice
Signed-off-by: Philippe Blain
Add a new advice type 'submoduleMergeConflict' for the error message shown when a non-trivial submodule conflict is encountered, which was added in 4057523 ("submodule merge: update conflict error message", 2022-08-04, Git v2.38.0-rc0 -- merge listed in batch #15).
That commit mentions making this message an advice as possible future work.
The message can now be disabled with the advice mechanism.
Update the tests as the expected message now appears on stderr instead of stdout.
git config
now includes in its man page:
submoduleMergeConflict
Advice shown when a non-trivial submodule merge conflict is
encountered.