To verify if a commit is an ancestor of another commit, the best solution is to run the following command:
git merge-base --is-ancestor <possible-descendant-commit-hash> <possible-ancestor-commit-hash>; echo $?
It will output 1, if possible-ancestor-commit-hash is an ancestor of possible-descendant-commit-hash.