Skip to content

Commit f261515

Browse files
Only verify the parent commit when it is going to be used
Moved the parent verification inside the branch that actually depends on the parent. Without that it fails needlessly when there is no parent yet.
1 parent 1348bbe commit f261515

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/git-subrepo

+12-11
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,19 @@ subrepo:branch() {
701701

702702
o "Subrepo parent: $subrepo_parent"
703703

704-
# Check if the subrepo parent is an ancestor of HEAD.
705-
# For example rebasing the commit that touched the subrepo
706-
# could make the commit no longer match.
707-
local parent_is_ancestor=
708-
git merge-base --is-ancestor "$subrepo_parent" HEAD && parent_is_ancestor="true"
709-
if [[ -z "$parent_is_ancestor" ]]; then
710-
error "The previous commit where the subrepo was updated, '$subrepo_parent' is not an ancestor of HEAD. \n \
711-
Did you rebase that commit?\n \
712-
Try manually setting subrepo.parent in .gitrepo to the hash of the correct commit."
713-
fi
714-
715704
if [[ -n "$subrepo_parent" ]]; then
705+
706+
# Check if the subrepo parent is an ancestor of HEAD.
707+
# For example rebasing the commit that touched the subrepo
708+
# could make the commit no longer match.
709+
local parent_is_ancestor=
710+
git merge-base --is-ancestor "$subrepo_parent" HEAD && parent_is_ancestor="true"
711+
if [[ -z "$parent_is_ancestor" ]]; then
712+
error "The previous commit where the subrepo was updated, '$subrepo_parent' is not an ancestor of HEAD. \n \
713+
Did you rebase that commit?\n \
714+
Try manually setting subrepo.parent in .gitrepo to the hash of the correct commit."
715+
fi
716+
716717
local prev_commit=
717718
local ancestor=
718719
o "Create new commits with parents into the subrepo fetch"

0 commit comments

Comments
 (0)