]> git.ipfire.org Git - thirdparty/git.git/blobdiff - worktree.h
hash-ll.h: split out of hash.h to remove dependency on repository.h
[thirdparty/git.git] / worktree.h
index 9e06fcbdf3d53f724ba6746db04db1ffd40e800f..ce45b66de9e82d4d619b6f74e0e77c8bd5ab3f53 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef WORKTREE_H
 #define WORKTREE_H
 
-#include "cache.h"
 #include "refs.h"
 
 struct strbuf;
@@ -149,6 +148,12 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
                                          const char *symref,
                                          const char *target);
 
+/*
+ * Returns true if a symref points to a ref in a worktree.
+ */
+int is_shared_symref(const struct worktree *wt,
+                    const char *symref, const char *target);
+
 /*
  * Similar to head_ref() for all HEADs _except_ one from the current
  * worktree, which is covered by head_ref().
@@ -166,16 +171,6 @@ const char *worktree_git_path(const struct worktree *wt,
                              const char *fmt, ...)
        __attribute__((format (printf, 2, 3)));
 
-/*
- * Parse a worktree ref (i.e. with prefix main-worktree/ or
- * worktrees/) and return the position of the worktree's name and
- * length (or NULL and zero if it's main worktree), and ref.
- *
- * All name, name_length and ref arguments could be NULL.
- */
-int parse_worktree_ref(const char *worktree_ref, const char **name,
-                      int *name_length, const char **ref);
-
 /*
  * Return a refname suitable for access from the current ref store.
  */
@@ -183,4 +178,25 @@ void strbuf_worktree_ref(const struct worktree *wt,
                         struct strbuf *sb,
                         const char *refname);
 
+/**
+ * Enable worktree config for the first time. This will make the following
+ * adjustments:
+ *
+ * 1. Add extensions.worktreeConfig=true in the common config file.
+ *
+ * 2. If the common config file has a core.worktree value, then that value
+ *    is moved to the main worktree's config.worktree file.
+ *
+ * 3. If the common config file has a core.bare enabled, then that value
+ *    is moved to the main worktree's config.worktree file.
+ *
+ * If extensions.worktreeConfig is already true, then this method
+ * terminates early without any of the above steps. The existing config
+ * arrangement is assumed to be intentional.
+ *
+ * Returns 0 on success. Reports an error message and returns non-zero
+ * if any of these steps fail.
+ */
+int init_worktree_config(struct repository *r);
+
 #endif