| 1587 | } |
| 1588 | |
| 1589 | static void send_rules(int f_out, filter_rule_list *flp) |
| 1590 | { |
| 1591 | filter_rule *ent; |
| 1592 | |
| 1593 | for (ent = flp->head; ent; ent = ent->next) { |
| 1594 | unsigned int len, plen, dlen; |
| 1595 | int elide = 0; |
| 1596 | char *p; |
| 1597 | |
| 1598 | /* Note we need to check delete_excluded here in addition to |
| 1599 | * the code in parse_rule_tok() because some rules may have |
| 1600 | * been added before we found the --delete-excluded option. |
| 1601 | * We must also elide any CVS merge-file rules to avoid a |
| 1602 | * backward compatibility problem, and we elide any no-prefix |
| 1603 | * merge files as an optimization (since they can only have |
| 1604 | * include/exclude rules). */ |
| 1605 | if (ent->rflags & FILTRULE_SENDER_SIDE) |
| 1606 | elide = am_sender ? LOCAL_RULE : REMOTE_RULE; |
| 1607 | if (ent->rflags & FILTRULE_RECEIVER_SIDE) |
| 1608 | elide = elide ? 0 : am_sender ? REMOTE_RULE : LOCAL_RULE; |
| 1609 | else if (delete_excluded && !elide |
| 1610 | && (!(ent->rflags & FILTRULE_PERDIR_MERGE) |
| 1611 | || ent->rflags & FILTRULE_NO_PREFIXES)) |
| 1612 | elide = am_sender ? LOCAL_RULE : REMOTE_RULE; |
| 1613 | ent->elide = elide; |
| 1614 | if (elide == LOCAL_RULE) |
| 1615 | continue; |
| 1616 | if (ent->rflags & FILTRULE_CVS_IGNORE |
| 1617 | && !(ent->rflags & FILTRULE_MERGE_FILE)) { |
| 1618 | int f = am_sender || protocol_version < 29 ? f_out : -2; |
| 1619 | send_rules(f, &cvs_filter_list); |
| 1620 | if (f == f_out) |
| 1621 | continue; |
| 1622 | } |
| 1623 | p = get_rule_prefix(ent, ent->pattern, 1, &plen); |
| 1624 | if (!p) { |
| 1625 | rprintf(FERROR, |
| 1626 | "filter rules are too modern for remote rsync.\n"); |
| 1627 | exit_cleanup(RERR_PROTOCOL); |
| 1628 | } |
| 1629 | if (f_out < 0) |
| 1630 | continue; |
| 1631 | len = strlen(ent->pattern); |
| 1632 | dlen = ent->rflags & FILTRULE_DIRECTORY ? 1 : 0; |
| 1633 | if (!(plen + len + dlen)) |
| 1634 | continue; |
| 1635 | write_int(f_out, plen + len + dlen); |
| 1636 | if (plen) |
| 1637 | write_buf(f_out, p, plen); |
| 1638 | write_buf(f_out, ent->pattern, len); |
| 1639 | if (dlen) |
| 1640 | write_byte(f_out, '/'); |
| 1641 | } |
| 1642 | } |
| 1643 | |
| 1644 | /* This is only called by the client. */ |
| 1645 | void send_filter_list(int f_out) |
no test coverage detected