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

Function scan_hunk_header

builtin/patch-id.c:32–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32static int scan_hunk_header(const char *p, int *p_before, int *p_after)
33{
34 static const char digits[] = "0123456789";
35 const char *q, *r;
36 int n;
37
38 q = p + 4;
39 n = strspn(q, digits);
40 if (q[n] == ',') {
41 q += n + 1;
42 *p_before = atoi(q);
43 n = strspn(q, digits);
44 } else {
45 *p_before = 1;
46 }
47
48 if (n == 0 || q[n] != ' ' || q[n+1] != '+')
49 return 0;
50
51 r = q + n + 2;
52 n = strspn(r, digits);
53 if (r[n] == ',') {
54 r += n + 1;
55 *p_after = atoi(r);
56 n = strspn(r, digits);
57 } else {
58 *p_after = 1;
59 }
60 if (n == 0)
61 return 0;
62
63 return 1;
64}
65
66static size_t get_one_patchid(struct object_id *next_oid, struct object_id *result,
67 struct strbuf *line_buf, int stable, int verbatim)

Callers 1

get_one_patchidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected