]> git.ipfire.org Git - thirdparty/git.git/blame - branch.h
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / branch.h
CommitLineData
e496c003
DB
1#ifndef BRANCH_H
2#define BRANCH_H
3
4edce172 4struct repository;
ef3ca954
EN
5struct strbuf;
6
e730b81d
EN
7enum branch_track {
8 BRANCH_TRACK_UNSPECIFIED = -1,
9 BRANCH_TRACK_NEVER = 0,
10 BRANCH_TRACK_REMOTE,
11 BRANCH_TRACK_ALWAYS,
12 BRANCH_TRACK_EXPLICIT,
d3115660
JS
13 BRANCH_TRACK_OVERRIDE,
14 BRANCH_TRACK_INHERIT,
e730b81d
EN
15};
16
17extern enum branch_track git_branch_track;
18
c369e7b8
DB
19/* Functions for acting on the information about branches. */
20
21/*
4bd488ea
JK
22 * Creates a new branch, where:
23 *
4edce172
NTND
24 * - r is the repository to add a branch to
25 *
4bd488ea
JK
26 * - name is the new branch name
27 *
28 * - start_name is the name of the existing branch that the new branch should
29 * start from
30 *
31 * - force enables overwriting an existing (non-head) branch
32 *
f6cea74d
KS
33 * - clobber_head_ok allows the currently checked out (hence existing)
34 * branch to be overwritten; without 'force', it has no effect.
35 *
4bd488ea
JK
36 * - reflog creates a reflog for the branch
37 *
f6cea74d
KS
38 * - quiet suppresses tracking information
39 *
4bd488ea
JK
40 * - track causes the new branch to be configured to merge the remote branch
41 * that start_name is a tracking branch for (if any).
e2bbd0cc 42 *
c369e7b8 43 */
4edce172
NTND
44void create_branch(struct repository *r,
45 const char *name, const char *start_name,
e2bbd0cc
KS
46 int force, int clobber_head_ok,
47 int reflog, int quiet, enum branch_track track);
e496c003 48
55c4a673 49/*
bc1c9c0e
JH
50 * Check if 'name' can be a valid name for a branch; die otherwise.
51 * Return 1 if the named branch already exists; return 0 otherwise.
52 * Fill ref with the full refname for the branch.
53 */
55454427 54int validate_branchname(const char *name, struct strbuf *ref);
bc1c9c0e
JH
55
56/*
57 * Check if a branch 'name' can be created as a new branch; die otherwise.
58 * 'force' can be used when it is OK for the named branch already exists.
59 * Return 1 if the named branch already exists; return 0 otherwise.
60 * Fill ref with the full refname for the branch.
55c4a673 61 */
55454427 62int validate_new_branchname(const char *name, struct strbuf *ref, int force);
55c4a673 63
b6433555
NTND
64/*
65 * Remove information about the merge state on the current
66 * branch. (E.g., MERGE_HEAD)
67 */
68void remove_merge_branch_state(struct repository *r);
69
c369e7b8
DB
70/*
71 * Remove information about the state of working on the current
72 * branch. (E.g., MERGE_HEAD)
73 */
f4a4b9ac 74void remove_branch_state(struct repository *r, int verbose);
c369e7b8 75
a9f2c136 76/*
13931236
MM
77 * Configure local branch "local" as downstream to branch "remote"
78 * from remote "origin". Used by git branch --set-upstream.
27852b2c 79 * Returns 0 on success.
a9f2c136
JH
80 */
81#define BRANCH_CONFIG_VERBOSE 01
55454427 82int install_branch_config(int flag, const char *local, const char *origin, const char *remote);
a9f2c136 83
6f9a3321
JH
84/*
85 * Read branch description
86 */
55454427 87int read_branch_desc(struct strbuf *, const char *branch_name);
6f9a3321 88
ed89f84b
ES
89/*
90 * Check if a branch is checked out in the main worktree or any linked
91 * worktree and die (with a message describing its checkout location) if
92 * it is.
93 */
55454427 94void die_if_checked_out(const char *branch, int ignore_current_worktree);
ed89f84b 95
70999e9c
KY
96/*
97 * Update all per-worktree HEADs pointing at the old ref to point the new ref.
98 * This will be used when renaming a branch. Returns 0 if successful, non-zero
99 * otherwise.
100 */
55454427 101int replace_each_worktree_head_symref(const char *oldref, const char *newref,
ad6dad09 102 const char *logmsg);
70999e9c 103
e496c003 104#endif