git/worktree.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "abspath.h"
#include "environment.h"
#include "gettext.h"
#include "path.h"
#include "repository.h"
#include "refs.h"
#include "setup.h"
#include "strbuf.h"
#include "worktree.h"
#include "dir.h"
#include "wt-status.h"
#include "config.h"

void free_worktree(struct worktree *worktree)
{}

void free_worktrees(struct worktree **worktrees)
{}

/**
 * Update head_oid, head_ref and is_detached of the given worktree
 */
static void add_head_info(struct worktree *wt)
{}

static int is_current_worktree(struct worktree *wt)
{}

/**
 * get the main worktree
 */
static struct worktree *get_main_worktree(int skip_reading_head)
{}

struct worktree *get_linked_worktree(const char *id,
				     int skip_reading_head)
{}

/*
 * NEEDSWORK: This function exists so that we can look up metadata of a
 * worktree without trying to access any of its internals like the refdb. It
 * would be preferable to instead have a corruption-tolerant function for
 * retrieving worktree metadata that could be used when the worktree is known
 * to not be in a healthy state, e.g. when creating or repairing it.
 */
static struct worktree **get_worktrees_internal(int skip_reading_head)
{}

struct worktree **get_worktrees(void)
{}

const char *get_worktree_git_dir(const struct worktree *wt)
{}

static struct worktree *find_worktree_by_suffix(struct worktree **list,
						const char *suffix)
{}

struct worktree *find_worktree(struct worktree **list,
			       const char *prefix,
			       const char *arg)
{}

struct worktree *find_worktree_by_path(struct worktree **list, const char *p)
{}

int is_main_worktree(const struct worktree *wt)
{}

const char *worktree_lock_reason(struct worktree *wt)
{}

const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire)
{}

/* convenient wrapper to deal with NULL strbuf */
__attribute__((format (printf, 2, 3)))
static void strbuf_addf_gently(struct strbuf *buf, const char *fmt, ...)
{}

int validate_worktree(const struct worktree *wt, struct strbuf *errmsg,
		      unsigned flags)
{}

void update_worktree_location(struct worktree *wt, const char *path_)
{}

int is_worktree_being_rebased(const struct worktree *wt,
			      const char *target)
{}

int is_worktree_being_bisected(const struct worktree *wt,
			       const char *target)
{}

/*
 * note: this function should be able to detect shared symref even if
 * HEAD is temporarily detached (e.g. in the middle of rebase or
 * bisect). New commands that do similar things should update this
 * function as well.
 */
int is_shared_symref(const struct worktree *wt, const char *symref,
		     const char *target)
{}

const struct worktree *find_shared_symref(struct worktree **worktrees,
					  const char *symref,
					  const char *target)
{}

int submodule_uses_worktrees(const char *path)
{}

void strbuf_worktree_ref(const struct worktree *wt,
			 struct strbuf *sb,
			 const char *refname)
{}

int other_head_refs(each_ref_fn fn, void *cb_data)
{}

/*
 * Repair worktree's /path/to/worktree/.git file if missing, corrupt, or not
 * pointing at <repo>/worktrees/<id>.
 */
static void repair_gitfile(struct worktree *wt,
			   worktree_repair_fn fn, void *cb_data)
{}

static void repair_noop(int iserr UNUSED,
			const char *path UNUSED,
			const char *msg UNUSED,
			void *cb_data UNUSED)
{}

void repair_worktrees(worktree_repair_fn fn, void *cb_data)
{}

static int is_main_worktree_path(const char *path)
{}

/*
 * If both the main worktree and linked worktree have been moved, then the
 * gitfile /path/to/worktree/.git won't point into the repository, thus we
 * won't know which <repo>/worktrees/<id>/gitdir to repair. However, we may
 * be able to infer the gitdir by manually reading /path/to/worktree/.git,
 * extracting the <id>, and checking if <repo>/worktrees/<id> exists.
 */
static char *infer_backlink(const char *gitfile)
{}

/*
 * Repair <repo>/worktrees/<id>/gitdir if missing, corrupt, or not pointing at
 * the worktree's path.
 */
void repair_worktree_at_path(const char *path,
			     worktree_repair_fn fn, void *cb_data)
{}

int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, timestamp_t expire)
{}

static int move_config_setting(const char *key, const char *value,
			       const char *from_file, const char *to_file)
{}

int init_worktree_config(struct repository *r)
{}