Does the ancestor repository actually track anything inside this directory? * Emptiness distinguishes "a scratch folder that merely sits under a repo" from * "a genuine subdirectory of one". Output is capped: we only care whether the * first byte exists, never what it is. */
| 476 | * "a genuine subdirectory of one". Output is capped: we only care whether the |
| 477 | * first byte exists, never what it is. */ |
| 478 | static watcher_git_status_t git_tracks_anything_here(cbm_watcher_t *w, project_state_t *state, |
| 479 | bool *tracked_out) { |
| 480 | *tracked_out = false; |
| 481 | const char *argv[] = {"git", "-C", state->root_path, "ls-files", "-z", "--", ".", NULL}; |
| 482 | watcher_git_output_t output; |
| 483 | watcher_git_status_t status = watcher_git_run(w, state, argv, WATCHER_GIT_HEAD_MAX, &output); |
| 484 | if (status != WATCHER_GIT_OK) { |
| 485 | return status; |
| 486 | } |
| 487 | FILE *fp = cbm_fopen(output.path, "rb"); |
| 488 | if (fp) { |
| 489 | *tracked_out = fgetc(fp) != EOF; |
| 490 | (void)fclose(fp); |
| 491 | } |
| 492 | watcher_git_output_cleanup(&output); |
| 493 | return fp ? WATCHER_GIT_OK : WATCHER_GIT_SUPERVISION_FAILED; |
| 494 | } |
| 495 | |
| 496 | /* Relative hop from root_path up to the repository root, as `git rev-parse |
| 497 | * --show-cdup` reports it ("" at the root, "../" one level down, and so on). |
no test coverage detected