MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / df_hunk_header

Function df_hunk_header

src/mcp/test_impact_diff.c:102–118  ·  view source on GitHub ↗

"@@ -a[,b] +c[,d] @@": the old and new line ranges. */

Source from the content-addressed store, hash-verified

100
101/* "@@ -a[,b] +c[,d] @@": the old and new line ranges. */
102static bool df_hunk_header(const df_line_t *line, int *old_count, int *new_start, int *new_count) {
103 static const char open[] = "@@ ";
104 const char *p = line->text + (sizeof(open) - 1);
105 const char *end = line->text + line->len;
106 int old_start = 0;
107 if (!df_starts(line, open) || !df_range(&p, end, '-', &old_start, old_count)) {
108 return false;
109 }
110 if (p >= end || *p != ' ') {
111 return false;
112 }
113 p++;
114 if (!df_range(&p, end, '+', new_start, new_count)) {
115 return false;
116 }
117 return (size_t)(end - p) >= 3 && memcmp(p, " @@", 3) == 0;
118}
119
120/* The path of "diff --git a/P b/P". Without renames both sides name the same
121 * file, so the line is the path twice; that also reads a path with " b/" in

Callers 1

df_readFunction · 0.85

Calls 2

df_startsFunction · 0.85
df_rangeFunction · 0.85

Tested by

no test coverage detected