| 991 | } |
| 992 | |
| 993 | static int do_compare_entry(const struct cache_entry *ce, |
| 994 | const struct traverse_info *info, |
| 995 | const char *name, size_t namelen, |
| 996 | unsigned mode) |
| 997 | { |
| 998 | int pathlen, ce_len; |
| 999 | const char *ce_name; |
| 1000 | int cmp; |
| 1001 | unsigned ce_mode; |
| 1002 | |
| 1003 | /* |
| 1004 | * If we have not precomputed the traverse path, it is quicker |
| 1005 | * to avoid doing so. But if we have precomputed it, |
| 1006 | * it is quicker to use the precomputed version. |
| 1007 | */ |
| 1008 | if (!info->traverse_path) |
| 1009 | return do_compare_entry_piecewise(ce, info, name, namelen, mode); |
| 1010 | |
| 1011 | cmp = strncmp(ce->name, info->traverse_path, info->pathlen); |
| 1012 | if (cmp) |
| 1013 | return cmp; |
| 1014 | |
| 1015 | pathlen = info->pathlen; |
| 1016 | ce_len = ce_namelen(ce); |
| 1017 | |
| 1018 | if (ce_len < pathlen) |
| 1019 | return -1; |
| 1020 | |
| 1021 | ce_len -= pathlen; |
| 1022 | ce_name = ce->name + pathlen; |
| 1023 | |
| 1024 | ce_mode = S_ISSPARSEDIR(ce->ce_mode) ? S_IFDIR : S_IFREG; |
| 1025 | return df_name_compare(ce_name, ce_len, ce_mode, name, namelen, mode); |
| 1026 | } |
| 1027 | |
| 1028 | static int compare_entry(const struct cache_entry *ce, const struct traverse_info *info, const struct name_entry *n) |
| 1029 | { |
no test coverage detected