2015-10-02 19:55:31 +08:00
|
|
|
#ifndef WORKTREE_H
|
|
|
|
#define WORKTREE_H
|
|
|
|
|
2015-10-09 01:01:03 +08:00
|
|
|
struct worktree {
|
|
|
|
char *path;
|
2016-04-22 21:01:26 +08:00
|
|
|
char *id;
|
2015-10-09 01:01:04 +08:00
|
|
|
char *head_ref;
|
|
|
|
unsigned char head_sha1[20];
|
|
|
|
int is_detached;
|
|
|
|
int is_bare;
|
2016-04-22 21:01:28 +08:00
|
|
|
int is_current;
|
2015-10-09 01:01:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Functions for acting on the information about worktrees. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the worktrees. The primary worktree will always be the first returned,
|
|
|
|
* and linked worktrees will be pointed to by 'next' in each subsequent
|
|
|
|
* worktree. No specific ordering is done on the linked worktrees.
|
|
|
|
*
|
|
|
|
* The caller is responsible for freeing the memory from the returned
|
|
|
|
* worktree(s).
|
|
|
|
*/
|
|
|
|
extern struct worktree **get_worktrees(void);
|
|
|
|
|
2016-04-22 21:01:26 +08:00
|
|
|
/*
|
|
|
|
* Return git dir of the worktree. Note that the path may be relative.
|
|
|
|
* If wt is NULL, git dir of current worktree is returned.
|
|
|
|
*/
|
|
|
|
extern const char *get_worktree_git_dir(const struct worktree *wt);
|
|
|
|
|
2015-10-09 01:01:03 +08:00
|
|
|
/*
|
|
|
|
* Free up the memory for worktree(s)
|
|
|
|
*/
|
|
|
|
extern void free_worktrees(struct worktree **);
|
|
|
|
|
2015-10-02 19:55:31 +08:00
|
|
|
/*
|
|
|
|
* Check if a per-worktree symref points to a ref in the main worktree
|
2016-04-22 21:01:27 +08:00
|
|
|
* or any linked worktree, and return the worktree that holds the ref,
|
|
|
|
* or NULL otherwise. The result may be destroyed by the next call.
|
2015-10-02 19:55:31 +08:00
|
|
|
*/
|
2016-04-22 21:01:27 +08:00
|
|
|
extern const struct worktree *find_shared_symref(const char *symref,
|
|
|
|
const char *target);
|
2015-10-02 19:55:31 +08:00
|
|
|
|
2016-04-22 21:01:36 +08:00
|
|
|
int is_worktree_being_rebased(const struct worktree *wt, const char *target);
|
|
|
|
int is_worktree_being_bisected(const struct worktree *wt, const char *target);
|
|
|
|
|
2016-04-22 21:01:29 +08:00
|
|
|
/*
|
|
|
|
* Similar to git_path() but can produce paths for a specified
|
|
|
|
* worktree instead of current one
|
|
|
|
*/
|
|
|
|
extern const char *worktree_git_path(const struct worktree *wt,
|
|
|
|
const char *fmt, ...)
|
|
|
|
__attribute__((format (printf, 2, 3)));
|
|
|
|
|
2015-10-02 19:55:31 +08:00
|
|
|
#endif
|