1#ifndef BRANCH_H 2#define BRANCH_H 3 4struct strbuf; 5 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 15externenum branch_track git_branch_track; 16 17/* Functions for acting on the information about branches. */ 18 19/* 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 * 29 * - clobber_head_ok allows the currently checked out (hence existing) 30 * branch to be overwritten; without 'force', it has no effect. 31 * 32 * - reflog creates a reflog for the branch 33 * 34 * - quiet suppresses tracking information 35 * 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). 38 * 39 */ 40voidcreate_branch(const char*name,const char*start_name, 41int force,int clobber_head_ok, 42int reflog,int quiet,enum branch_track track); 43 44/* 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 */ 49externintvalidate_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. 56 */ 57externintvalidate_new_branchname(const char*name,struct strbuf *ref,int force); 58 59/* 60 * Remove information about the state of working on the current 61 * branch. (E.g., MERGE_HEAD) 62 */ 63voidremove_branch_state(void); 64 65/* 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. 69 */ 70#define BRANCH_CONFIG_VERBOSE 01 71externintinstall_branch_config(int flag,const char*local,const char*origin,const char*remote); 72 73/* 74 * Read branch description 75 */ 76externintread_branch_desc(struct strbuf *,const char*branch_name); 77 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 */ 83externvoiddie_if_checked_out(const char*branch,int ignore_current_worktree); 84 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 */ 90externintreplace_each_worktree_head_symref(const char*oldref,const char*newref, 91const char*logmsg); 92 93#endif