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

Function prepare_order

diffcore-order.c:14–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12static int order_cnt;
13
14static void prepare_order(const char *orderfile)
15{
16 int cnt, pass;
17 struct strbuf sb = STRBUF_INIT;
18 const char *cp, *endp;
19 ssize_t sz;
20
21 if (order)
22 return;
23
24 sz = strbuf_read_file(&sb, orderfile, 0);
25 if (sz < 0)
26 die_errno(_("failed to read orderfile '%s'"), orderfile);
27 endp = sb.buf + sz;
28
29 for (pass = 0; pass < 2; pass++) {
30 cnt = 0;
31 cp = sb.buf;
32 while (cp < endp) {
33 const char *ep;
34 for (ep = cp; ep < endp && *ep != '\n'; ep++)
35 ;
36 /* cp to ep has one line */
37 if (*cp == '\n' || *cp == '#')
38 ; /* comment */
39 else if (pass == 0)
40 cnt++;
41 else {
42 order[cnt] = xmemdupz(cp, ep - cp);
43 cnt++;
44 }
45 if (ep < endp)
46 ep++;
47 cp = ep;
48 }
49 if (pass == 0) {
50 order_cnt = cnt;
51 ALLOC_ARRAY(order, cnt);
52 }
53 }
54
55 strbuf_release(&sb);
56}
57
58static int match_order(const char *path)
59{

Callers 1

order_objectsFunction · 0.85

Calls 4

strbuf_read_fileFunction · 0.85
die_errnoFunction · 0.85
xmemdupzFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected