| 1102 | } check_rules_opts; |
| 1103 | |
| 1104 | static int check_rules(struct repository *repo, |
| 1105 | struct pattern_list *pl, |
| 1106 | int null_terminated) |
| 1107 | { |
| 1108 | struct strbuf line = STRBUF_INIT; |
| 1109 | struct strbuf unquoted = STRBUF_INIT; |
| 1110 | char *path; |
| 1111 | int line_terminator = null_terminated ? 0 : '\n'; |
| 1112 | strbuf_getline_fn getline_fn = null_terminated ? strbuf_getline_nul |
| 1113 | : strbuf_getline; |
| 1114 | repo->index->sparse_checkout_patterns = pl; |
| 1115 | while (!getline_fn(&line, stdin)) { |
| 1116 | path = line.buf; |
| 1117 | if (!null_terminated && line.buf[0] == '"') { |
| 1118 | strbuf_reset(&unquoted); |
| 1119 | if (unquote_c_style(&unquoted, line.buf, NULL)) |
| 1120 | die(_("unable to unquote C-style string '%s'"), |
| 1121 | line.buf); |
| 1122 | |
| 1123 | path = unquoted.buf; |
| 1124 | } |
| 1125 | |
| 1126 | if (path_in_sparse_checkout(path, repo->index)) |
| 1127 | write_name_quoted(path, stdout, line_terminator); |
| 1128 | } |
| 1129 | strbuf_release(&line); |
| 1130 | strbuf_release(&unquoted); |
| 1131 | |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
| 1135 | static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix, |
| 1136 | struct repository *repo) |
no test coverage detected