Skip to content

Commit

Permalink
Add context for missing parent error message
Browse files Browse the repository at this point in the history
I did not find it immediately obvious how to gather the
information needed to fix a missing parent error. Search the
repository for the values needed and present them as part of the
message.

Fixes #617, #415, #600
  • Loading branch information
admorgan committed Jul 22, 2024
1 parent cc0e29f commit e7411ba
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/git-subrepo
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,16 @@ subrepo:branch() {
local parent_is_ancestor=
git merge-base --is-ancestor "$subrepo_parent" HEAD && parent_is_ancestor="true"
if [[ -z "$parent_is_ancestor" ]]; then
error "The previous commit where the subrepo was updated, '$subrepo_parent' is not an ancestor of HEAD. \n \
Did you rebase that commit?\n \
Try manually setting subrepo.parent in .gitrepo to the hash of the correct commit."
local prev_merge_point
prev_merge_point=$(git log -1 -G "commit =" --format="%H" "$gitrepo")
# We want the SHA of the patch before the sync point just in case someone made a modifcation in the
# actual sync commit
prev_merge_point=$(git log -1 --format="%H" "$prev_merge_point"^)
error "The last sync point (where upstream and the subrepo were equal) is not an ancestor. \n \
This is usually caused by a rebase affecting that commit. \n \
To recover set the subrepo parent in '$gitrepo'\n \
to '$prev_merge_point' \n \
and validate the subrepo by comparing with 'git subrepo branch $subdir'"
fi

local prev_commit=
Expand Down

0 comments on commit e7411ba

Please sign in to comment.