builtin-branch: factor out merge_filter matching