summaryrefslogtreecommitdiff
path: root/worktree.h
diff options
context:
space:
mode:
authorRafael Silva <rafaeloliveira.cs@gmail.com>2021-01-19 21:27:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-30 17:57:08 (GMT)
commita29a8b7574ab34026252691933f462eddc59146a (patch)
tree63f26ea5798bce6632dff33f04f949f4f3f8fc92 /worktree.h
parent66e871b6647ffea61a77a0f82c7ef3415f1ee79c (diff)
downloadgit-a29a8b7574ab34026252691933f462eddc59146a.zip
git-a29a8b7574ab34026252691933f462eddc59146a.tar.gz
git-a29a8b7574ab34026252691933f462eddc59146a.tar.bz2
worktree: libify should_prune_worktree()
As part of teaching "git worktree list" to annotate worktree that is a candidate for pruning, let's move should_prune_worktree() from builtin/worktree.c to worktree.c in order to make part of the worktree public API. should_prune_worktree() knows how to select the given worktree for pruning based on an expiration date, however the expiration value is stored in a static file-scope variable and it is not local to the function. In order to move the function, teach should_prune_worktree() to take the expiration date as an argument and document the new parameter that is not immediately obvious. Also, change the function comment to clearly state that the worktree's path is returned in `wtpath` argument. 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.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/worktree.h b/worktree.h
index f38e6fd..818e149 100644
--- a/worktree.h
+++ b/worktree.h
@@ -73,6 +73,20 @@ int is_main_worktree(const struct worktree *wt);
*/
const char *worktree_lock_reason(struct worktree *wt);
+/*
+ * 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
+ * returned path.
+ *
+ * `expire` defines a grace period to prune the worktree when its path
+ * does not exist.
+ */
+int should_prune_worktree(const char *id,
+ struct strbuf *reason,
+ char **wtpath,
+ timestamp_t expire);
+
#define WT_VALIDATE_WORKTREE_MISSING_OK (1 << 0)
/*