THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.0KB

  1. #ifndef BRANCH_H
  2. #define BRANCH_H
  3. struct repository;
  4. struct strbuf;
  5. enum branch_track {
  6. BRANCH_TRACK_UNSPECIFIED = -1,
  7. BRANCH_TRACK_NEVER = 0,
  8. BRANCH_TRACK_REMOTE,
  9. BRANCH_TRACK_ALWAYS,
  10. BRANCH_TRACK_EXPLICIT,
  11. BRANCH_TRACK_OVERRIDE
  12. };
  13. extern enum branch_track git_branch_track;
  14. /* Functions for acting on the information about branches. */
  15. /*
  16. * Creates a new branch, where:
  17. *
  18. * - r is the repository to add a branch to
  19. *
  20. * - name is the new branch name
  21. *
  22. * - start_name is the name of the existing branch that the new branch should
  23. * start from
  24. *
  25. * - force enables overwriting an existing (non-head) branch
  26. *
  27. * - clobber_head_ok allows the currently checked out (hence existing)
  28. * branch to be overwritten; without 'force', it has no effect.
  29. *
  30. * - reflog creates a reflog for the branch
  31. *
  32. * - quiet suppresses tracking information
  33. *
  34. * - track causes the new branch to be configured to merge the remote branch
  35. * that start_name is a tracking branch for (if any).
  36. *
  37. */
  38. void create_branch(struct repository *r,
  39. const char *name, const char *start_name,
  40. int force, int clobber_head_ok,
  41. int reflog, int quiet, enum branch_track track);
  42. /*
  43. * Check if 'name' can be a valid name for a branch; die otherwise.
  44. * Return 1 if the named branch already exists; return 0 otherwise.
  45. * Fill ref with the full refname for the branch.
  46. */
  47. int validate_branchname(const char *name, struct strbuf *ref);
  48. /*
  49. * Check if a branch 'name' can be created as a new branch; die otherwise.
  50. * 'force' can be used when it is OK for the named branch already exists.
  51. * Return 1 if the named branch already exists; return 0 otherwise.
  52. * Fill ref with the full refname for the branch.
  53. */
  54. int validate_new_branchname(const char *name, struct strbuf *ref, int force);
  55. /*
  56. * Remove information about the merge state on the current
  57. * branch. (E.g., MERGE_HEAD)
  58. */
  59. void remove_merge_branch_state(struct repository *r);
  60. /*
  61. * Remove information about the state of working on the current
  62. * branch. (E.g., MERGE_HEAD)
  63. */
  64. void remove_branch_state(struct repository *r, int verbose);
  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
  71. int install_branch_config(int flag, const char *local, const char *origin, const char *remote);
  72. /*
  73. * Read branch description
  74. */
  75. int read_branch_desc(struct strbuf *, const char *branch_name);
  76. /*
  77. * Check if a branch is checked out in the main worktree or any linked
  78. * worktree and die (with a message describing its checkout location) if
  79. * it is.
  80. */
  81. void die_if_checked_out(const char *branch, int ignore_current_worktree);
  82. /*
  83. * Update all per-worktree HEADs pointing at the old ref to point the new ref.
  84. * This will be used when renaming a branch. Returns 0 if successful, non-zero
  85. * otherwise.
  86. */
  87. int replace_each_worktree_head_symref(const char *oldref, const char *newref,
  88. const char *logmsg);
  89. #endif