V3 API: best way to check if a commit is in a branch


The compare endpoint is documented as taking two branches (and returns the entire diff which is likely costly). I just want to know, given a commit c, whether it’s already in a branch B or not (aka whether c is an ancestor of B.head).

Is there a good way to do that, currently, in github? Possibly retrieving the branches a commit is part of given that’s actually displayed when viewing a commit via the web UI?