MCPcopy Index your code
hub / github.com/git/git / worktree_lock_reason

Function worktree_lock_reason

worktree.c:303–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303const 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
327const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire)
328{

Callers 7

check_candidate_pathFunction · 0.85
show_worktree_porcelainFunction · 0.85
show_worktreeFunction · 0.85
lock_worktreeFunction · 0.85
unlock_worktreeFunction · 0.85
move_worktreeFunction · 0.85
remove_worktreeFunction · 0.85

Calls 9

is_main_worktreeFunction · 0.85
strbuf_addstrFunction · 0.85
worktree_git_pathFunction · 0.85
file_existsFunction · 0.85
strbuf_read_fileFunction · 0.85
die_errnoFunction · 0.85
strbuf_trimFunction · 0.85
strbuf_detachFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected