| 1569 | } |
| 1570 | |
| 1571 | static int path_in_sparse_checkout_1(const char *path, |
| 1572 | struct index_state *istate, |
| 1573 | int require_cone_mode) |
| 1574 | { |
| 1575 | int dtype = DT_REG; |
| 1576 | enum pattern_match_result match = UNDECIDED; |
| 1577 | const char *end, *slash; |
| 1578 | |
| 1579 | /* |
| 1580 | * We default to accepting a path if the path is empty, there are no |
| 1581 | * patterns, or the patterns are of the wrong type. |
| 1582 | */ |
| 1583 | if (!*path || |
| 1584 | init_sparse_checkout_patterns(istate) || |
| 1585 | (require_cone_mode && |
| 1586 | !istate->sparse_checkout_patterns->use_cone_patterns)) |
| 1587 | return 1; |
| 1588 | |
| 1589 | /* |
| 1590 | * If UNDECIDED, use the match from the parent dir (recursively), or |
| 1591 | * fall back to NOT_MATCHED at the topmost level. Note that cone mode |
| 1592 | * never returns UNDECIDED, so we will execute only one iteration in |
| 1593 | * this case. |
| 1594 | */ |
| 1595 | for (end = path + strlen(path); |
| 1596 | end > path && match == UNDECIDED; |
| 1597 | end = slash) { |
| 1598 | |
| 1599 | for (slash = end - 1; slash > path && *slash != '/'; slash--) |
| 1600 | ; /* do nothing */ |
| 1601 | |
| 1602 | match = path_matches_pattern_list(path, end - path, |
| 1603 | slash > path ? slash + 1 : path, &dtype, |
| 1604 | istate->sparse_checkout_patterns, istate); |
| 1605 | |
| 1606 | /* We are going to match the parent dir now */ |
| 1607 | dtype = DT_DIR; |
| 1608 | } |
| 1609 | return match > 0; |
| 1610 | } |
| 1611 | |
| 1612 | int path_in_sparse_checkout(const char *path, |
| 1613 | struct index_state *istate) |
no test coverage detected