MCPcopy Create free account
hub / github.com/git/git / check_rules

Function check_rules

builtin/sparse-checkout.c:1104–1133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102} check_rules_opts;
1103
1104static 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
1135static int sparse_checkout_check_rules(int argc, const char **argv, const char *prefix,
1136 struct repository *repo)

Callers 1

Calls 5

unquote_c_styleFunction · 0.85
path_in_sparse_checkoutFunction · 0.85
write_name_quotedFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected