diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-01-08 11:05:43 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-01-08 13:17:30 -0800 |
commit | b8a846b2e03610e6f550d364c75e514532ef7adf (patch) | |
tree | efa9a3a57dd26a54323bd036a16ac2c103d4e129 /worktree.h | |
parent | 84f0ea956fbd3a3c9989a2d44da27881c0a5f546 (diff) | |
download | git-b8a846b2e03610e6f550d364c75e514532ef7adf.tar.gz |
worktree: expose interface to look up worktree by name
Our worktree interfaces do not provide a way to look up a worktree by
its name. Expose `get_linked_worktree()` to allow for this usecase. As
callers are responsible for freeing this worktree, introduce a new
function `free_worktree()` that does so.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.h')
-rw-r--r-- | worktree.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/worktree.h b/worktree.h index ce45b66de9..f14784a2ff 100644 --- a/worktree.h +++ b/worktree.h @@ -58,6 +58,13 @@ struct worktree *find_worktree(struct worktree **list, const char *arg); /* + * Look up the worktree corresponding to `id`, or NULL of no such worktree + * exists. + */ +struct worktree *get_linked_worktree(const char *id, + int skip_reading_head); + +/* * Return the worktree corresponding to `path`, or NULL if no such worktree * exists. */ @@ -135,6 +142,11 @@ void repair_worktrees(worktree_repair_fn, void *cb_data); void repair_worktree_at_path(const char *, worktree_repair_fn, void *cb_data); /* + * Free up the memory for a worktree. + */ +void free_worktree(struct worktree *); + +/* * Free up the memory for worktree(s) */ void free_worktrees(struct worktree **); |