]> git.ipfire.org Git - thirdparty/git.git/blame - branch.h
Sync with 2.18.2
[thirdparty/git.git] / branch.h
CommitLineData
e496c003
DB
1#ifndef BRANCH_H
2#define BRANCH_H
3
ef3ca954
EN
4struct strbuf;
5
e730b81d
EN
6enum 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
13};
14
15extern enum branch_track git_branch_track;
16
c369e7b8
DB
17/* Functions for acting on the information about branches. */
18
19/*
4bd488ea
JK
20 * Creates a new branch, where:
21 *
22 * - name is the new branch name
23 *
24 * - start_name is the name of the existing branch that the new branch should
25 * start from
26 *
27 * - force enables overwriting an existing (non-head) branch
28 *
f6cea74d
KS
29 * - clobber_head_ok allows the currently checked out (hence existing)
30 * branch to be overwritten; without 'force', it has no effect.
31 *
4bd488ea
JK
32 * - reflog creates a reflog for the branch
33 *
f6cea74d
KS
34 * - quiet suppresses tracking information
35 *
4bd488ea
JK
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).
e2bbd0cc 38 *
c369e7b8 39 */
4bd488ea 40void create_branch(const char *name, const char *start_name,
e2bbd0cc
KS
41 int force, int clobber_head_ok,
42 int reflog, int quiet, enum branch_track track);
e496c003 43
55c4a673 44/*
bc1c9c0e
JH
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.
48 */
49extern int validate_branchname(const char *name, struct strbuf *ref);
50
51/*
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.
55c4a673 56 */
bc1c9c0e 57extern int validate_new_branchname(const char *name, struct strbuf *ref, int force);
55c4a673 58
c369e7b8
DB
59/*
60 * Remove information about the state of working on the current
61 * branch. (E.g., MERGE_HEAD)
62 */
63void remove_branch_state(void);
64
a9f2c136 65/*
13931236
MM
66 * Configure local branch "local" as downstream to branch "remote"
67 * from remote "origin". Used by git branch --set-upstream.
27852b2c 68 * Returns 0 on success.
a9f2c136
JH
69 */
70#define BRANCH_CONFIG_VERBOSE 01
27852b2c 71extern int install_branch_config(int flag, const char *local, const char *origin, const char *remote);
a9f2c136 72
6f9a3321
JH
73/*
74 * Read branch description
75 */
76extern int read_branch_desc(struct strbuf *, const char *branch_name);
77
ed89f84b
ES
78/*
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.
82 */
8d9fdd70 83extern void die_if_checked_out(const char *branch, int ignore_current_worktree);
ed89f84b 84
70999e9c
KY
85/*
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.
89 */
39ee4c6c
KM
90extern int replace_each_worktree_head_symref(const char *oldref, const char *newref,
91 const char *logmsg);
70999e9c 92
e496c003 93#endif