checkout: avoid unnecessary match_pathspec calls