| 325 | } |
| 326 | |
| 327 | const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire) |
| 328 | { |
| 329 | struct strbuf reason = STRBUF_INIT; |
| 330 | char *path = NULL; |
| 331 | |
| 332 | if (is_main_worktree(wt)) |
| 333 | return NULL; |
| 334 | if (wt->prune_reason_valid) |
| 335 | return wt->prune_reason; |
| 336 | |
| 337 | if (should_prune_worktree(wt->id, &reason, &path, expire)) |
| 338 | wt->prune_reason = strbuf_detach(&reason, NULL); |
| 339 | wt->prune_reason_valid = 1; |
| 340 | |
| 341 | strbuf_release(&reason); |
| 342 | free(path); |
| 343 | return wt->prune_reason; |
| 344 | } |
| 345 | |
| 346 | /* convenient wrapper to deal with NULL strbuf */ |
| 347 | __attribute__((format (printf, 2, 3))) |
no test coverage detected