| 116 | #endif |
| 117 | |
| 118 | static bool is_git_repo(const char *root_path) { |
| 119 | char cmd[CBM_SZ_1K]; |
| 120 | snprintf(cmd, sizeof(cmd), "git -C \"%s\" rev-parse --git-dir 2>%s", root_path, WATCHER_NULDEV); |
| 121 | FILE *fp = cbm_popen(cmd, "r"); |
| 122 | if (!fp) { |
| 123 | return false; |
| 124 | } |
| 125 | /* Drain output so pclose gets a clean exit status. */ |
| 126 | char drain[CBM_SZ_128]; |
| 127 | while (fgets(drain, (int)sizeof(drain), fp)) { /* discard */ |
| 128 | } |
| 129 | int rc = cbm_pclose(fp); |
| 130 | return rc == 0; |
| 131 | } |
| 132 | |
| 133 | static int git_head(const char *root_path, char *out, size_t out_size) { |
| 134 | char cmd[CBM_SZ_1K]; |
no test coverage detected