| 301 | } |
| 302 | |
| 303 | const char *worktree_lock_reason(struct worktree *wt) |
| 304 | { |
| 305 | if (is_main_worktree(wt)) |
| 306 | return NULL; |
| 307 | |
| 308 | if (!wt->lock_reason_valid) { |
| 309 | struct strbuf path = STRBUF_INIT; |
| 310 | |
| 311 | strbuf_addstr(&path, worktree_git_path(wt, "locked")); |
| 312 | if (file_exists(path.buf)) { |
| 313 | struct strbuf lock_reason = STRBUF_INIT; |
| 314 | if (strbuf_read_file(&lock_reason, path.buf, 0) < 0) |
| 315 | die_errno(_("failed to read '%s'"), path.buf); |
| 316 | strbuf_trim(&lock_reason); |
| 317 | wt->lock_reason = strbuf_detach(&lock_reason, NULL); |
| 318 | } else |
| 319 | wt->lock_reason = NULL; |
| 320 | wt->lock_reason_valid = 1; |
| 321 | strbuf_release(&path); |
| 322 | } |
| 323 | |
| 324 | return wt->lock_reason; |
| 325 | } |
| 326 | |
| 327 | const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire) |
| 328 | { |
no test coverage detected