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

Function parse_one_name_status

src/pipeline/pass_gitdiff.c:47–85  ·  view source on GitHub ↗

Parse a single name-status line into a cbm_changed_file_t. * Returns true if a valid entry was produced. */

Source from the content-addressed store, hash-verified

45/* Parse a single name-status line into a cbm_changed_file_t.
46 * Returns true if a valid entry was produced. */
47static bool parse_one_name_status(const char *line, size_t line_len, cbm_changed_file_t *out_f) {
48 char tmp[HUNK_LINE_BUF];
49 if (line_len >= sizeof(tmp)) {
50 line_len = sizeof(tmp) - SKIP_ONE;
51 }
52 memcpy(tmp, line, line_len);
53 tmp[line_len] = '\0';
54
55 char *status_str = tmp;
56 char *tab1 = strchr(tmp, '\t');
57 if (!tab1) {
58 return false;
59 }
60 *tab1 = '\0';
61 char *path1 = tab1 + SKIP_ONE;
62
63 char *tab2 = strchr(path1, '\t');
64 char *path2 = NULL;
65 if (tab2) {
66 *tab2 = '\0';
67 path2 = tab2 + SKIP_ONE;
68 }
69
70 memset(out_f, 0, sizeof(*out_f));
71
72 if (status_str[0] == 'R') {
73 out_f->status[0] = 'R';
74 out_f->status[GD_STATUS_IDX] = '\0';
75 snprintf(out_f->old_path, sizeof(out_f->old_path), "%s", path1);
76 snprintf(out_f->path, sizeof(out_f->path), "%s", path2 ? path2 : path1);
77 } else {
78 out_f->status[0] = status_str[0];
79 out_f->status[GD_STATUS_IDX] = '\0';
80 snprintf(out_f->path, sizeof(out_f->path), "%s", path1);
81 out_f->old_path[0] = '\0';
82 }
83
84 return cbm_is_trackable_file(out_f->path);
85}
86
87int cbm_parse_name_status(const char *output, cbm_changed_file_t *out, int max_out) {
88 if (!output || !out || max_out <= 0) {

Callers 1

cbm_parse_name_statusFunction · 0.85

Calls 1

cbm_is_trackable_fileFunction · 0.85

Tested by

no test coverage detected