You could use `git_merge_base` here, instead, and then use a single variable for the merge base.  This also allows you to take a single element.  Eg:

```
base = inputs[0]
for (i = 1; i < len; i++)
    base = merge_base(base, inputs[i])
```