Folder key: the first two path components ("src/pipeline"), one for a * top-level directory, "." for repo-root files. */
| 135 | /* Folder key: the first two path components ("src/pipeline"), one for a |
| 136 | * top-level directory, "." for repo-root files. */ |
| 137 | static void rg_folder_key(const char *path, char *out, size_t cap) { |
| 138 | if (!path || !path[0]) { |
| 139 | snprintf(out, cap, "."); |
| 140 | return; |
| 141 | } |
| 142 | const char *first = strchr(path, '/'); |
| 143 | if (!first) { |
| 144 | snprintf(out, cap, "."); |
| 145 | return; |
| 146 | } |
| 147 | const char *second = strchr(first + 1, '/'); |
| 148 | size_t len = second ? (size_t)(second - path) : (size_t)(first - path); |
| 149 | if (len >= cap) |
| 150 | len = cap - 1; |
| 151 | memcpy(out, path, len); |
| 152 | out[len] = '\0'; |
| 153 | } |
| 154 | |
| 155 | typedef struct { |
| 156 | int64_t id; |
no outgoing calls
no test coverage detected