Merge branch 'sg/t3420-autostash-fix'
[git/debian.git] / branch.h
blob5cace4581fe43aa5fdc20b4315cee6eff1034003
1 #ifndef BRANCH_H
2 #define BRANCH_H
4 struct strbuf;
6 enum branch_track {
7 BRANCH_TRACK_UNSPECIFIED = -1,
8 BRANCH_TRACK_NEVER = 0,
9 BRANCH_TRACK_REMOTE,
10 BRANCH_TRACK_ALWAYS,
11 BRANCH_TRACK_EXPLICIT,
12 BRANCH_TRACK_OVERRIDE
15 extern enum branch_track git_branch_track;
17 /* Functions for acting on the information about branches. */
20 * Creates a new branch, where:
22 * - name is the new branch name
24 * - start_name is the name of the existing branch that the new branch should
25 * start from
27 * - force enables overwriting an existing (non-head) branch
29 * - clobber_head_ok allows the currently checked out (hence existing)
30 * branch to be overwritten; without 'force', it has no effect.
32 * - reflog creates a reflog for the branch
34 * - quiet suppresses tracking information
36 * - track causes the new branch to be configured to merge the remote branch
37 * that start_name is a tracking branch for (if any).
40 void create_branch(const char *name, const char *start_name,
41 int force, int clobber_head_ok,
42 int reflog, int quiet, enum branch_track track);
45 * Check if 'name' can be a valid name for a branch; die otherwise.
46 * Return 1 if the named branch already exists; return 0 otherwise.
47 * Fill ref with the full refname for the branch.
49 extern int validate_branchname(const char *name, struct strbuf *ref);
52 * Check if a branch 'name' can be created as a new branch; die otherwise.
53 * 'force' can be used when it is OK for the named branch already exists.
54 * Return 1 if the named branch already exists; return 0 otherwise.
55 * Fill ref with the full refname for the branch.
57 extern int validate_new_branchname(const char *name, struct strbuf *ref, int force);
60 * Remove information about the state of working on the current
61 * branch. (E.g., MERGE_HEAD)
63 void remove_branch_state(void);
66 * Configure local branch "local" as downstream to branch "remote"
67 * from remote "origin". Used by git branch --set-upstream.
68 * Returns 0 on success.
70 #define BRANCH_CONFIG_VERBOSE 01
71 extern int install_branch_config(int flag, const char *local, const char *origin, const char *remote);
74 * Read branch description
76 extern int read_branch_desc(struct strbuf *, const char *branch_name);
79 * Check if a branch is checked out in the main worktree or any linked
80 * worktree and die (with a message describing its checkout location) if
81 * it is.
83 extern void die_if_checked_out(const char *branch, int ignore_current_worktree);
86 * Update all per-worktree HEADs pointing at the old ref to point the new ref.
87 * This will be used when renaming a branch. Returns 0 if successful, non-zero
88 * otherwise.
90 extern int replace_each_worktree_head_symref(const char *oldref, const char *newref,
91 const char *logmsg);
93 #endif