mirror of
https://github.com/git/git
synced 2024-09-13 13:24:41 +00:00
subtree: use git merge-base --is-ancestor
Instead of writing a slow `rev_is_descendant_of_branch $a $b` function in shell, just use the fast `git merge-base --is-ancestor $b $a`. Signed-off-by: Luke Shumaker <lukeshu@datawire.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
8dc3240f5f
commit
f664304836
|
@ -280,20 +280,6 @@ rev_exists () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rev_is_descendant_of_branch () {
|
|
||||||
newrev="$1"
|
|
||||||
branch="$2"
|
|
||||||
branch_hash=$(git rev-parse "$branch")
|
|
||||||
match=$(git rev-list -1 "$branch_hash" "^$newrev")
|
|
||||||
|
|
||||||
if test -z "$match"
|
|
||||||
then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# if a commit doesn't have a parent, this might not work. But we only want
|
# if a commit doesn't have a parent, this might not work. But we only want
|
||||||
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
||||||
# be there anyway, so do nothing in that case.
|
# be there anyway, so do nothing in that case.
|
||||||
|
@ -811,7 +797,7 @@ cmd_split () {
|
||||||
then
|
then
|
||||||
if rev_exists "refs/heads/$branch"
|
if rev_exists "refs/heads/$branch"
|
||||||
then
|
then
|
||||||
if ! rev_is_descendant_of_branch "$latest_new" "$branch"
|
if ! git merge-base --is-ancestor "$branch" "$latest_new"
|
||||||
then
|
then
|
||||||
die "Branch '$branch' is not an ancestor of commit '$latest_new'."
|
die "Branch '$branch' is not an ancestor of commit '$latest_new'."
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue