diff options
author | Rafael Silva <rafaeloliveira.cs@gmail.com> | 2021-01-19 22:27:34 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-30 09:57:16 -0800 |
commit | fc0c7d5e9e9e396afdd669019e7635773b1d1423 (patch) | |
tree | ddf3a3ab934adb31ebc0181608d35555707a155b /worktree.h | |
parent | worktree: libify should_prune_worktree() (diff) | |
download | tgif-fc0c7d5e9e9e396afdd669019e7635773b1d1423.tar.xz |
worktree: teach worktree to lazy-load "prunable" reason
Add worktree_prune_reason() to allow a caller to discover whether a
worktree is prunable and the reason that it is, much like
worktree_lock_reason() indicates whether a worktree is locked and the
reason for the lock. As with worktree_lock_reason(), retrieve the
prunable reason lazily and cache it in the `worktree` structure.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Rafael Silva <rafaeloliveira.cs@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.h')
-rw-r--r-- | worktree.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/worktree.h b/worktree.h index 818e1491c7..8b7c408132 100644 --- a/worktree.h +++ b/worktree.h @@ -11,11 +11,13 @@ struct worktree { char *id; char *head_ref; /* NULL if HEAD is broken or detached */ char *lock_reason; /* private - use worktree_lock_reason */ + char *prune_reason; /* private - use worktree_prune_reason */ struct object_id head_oid; int is_detached; int is_bare; int is_current; int lock_reason_valid; /* private */ + int prune_reason_valid; /* private */ }; /* @@ -74,6 +76,13 @@ int is_main_worktree(const struct worktree *wt); const char *worktree_lock_reason(struct worktree *wt); /* + * Return the reason string if the given worktree should be pruned, otherwise + * NULL if it should not be pruned. `expire` defines a grace period to prune + * the worktree when its path does not exist. + */ +const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire); + +/* * Return true if worktree entry should be pruned, along with the reason for * pruning. Otherwise, return false and the worktree's path in `wtpath`, or * NULL if it cannot be determined. Caller is responsible for freeing |