Take branch into account when searching for commit