]> git.ipfire.org Git - thirdparty/git.git/blobdiff - worktree.h
tests: remove last uses of C_LOCALE_OUTPUT
[thirdparty/git.git] / worktree.h
index ff7b62e43414d24e5c61c619352f47f034484aeb..8b7c408132d1f7c7a81824f635488955a2df3cd6 100644 (file)
@@ -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 */
 };
 
 /*
@@ -73,6 +75,27 @@ 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
+ * 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)
 
 /*
@@ -159,11 +182,4 @@ void strbuf_worktree_ref(const struct worktree *wt,
                         struct strbuf *sb,
                         const char *refname);
 
-/*
- * Return a refname suitable for access from the current ref
- * store. The result will be destroyed at the next call.
- */
-const char *worktree_ref(const struct worktree *wt,
-                        const char *refname);
-
 #endif