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 ingydotnet#617, ingydotnet#415, ingydotnet#600
  • Loading branch information
admorgan committed Jul 11, 2024
1 parent 1e4ca5c commit 29a940f
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

2 comments on commit 29a940f

@JWCS
Copy link

@JWCS JWCS commented on 29a940f Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@admorgan Does this plan to get merged in soon? I saw that issue 617 was closed; but is this sufficient to solve trivial rebases?

@admorgan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been merged and is included in releases > 0.4.8. To be clear this will not "fix" anything. It will give you enough information to allow you to make an informed decision about how to proceed, but you will have to manually execute the solution as there is not enough information to do this automatically.

Please sign in to comment.