Skip to content

Commit 4bd488e

Browse files
peffgitster
authored andcommitted
create_branch: drop unused "head" parameter
This function used to have the caller pass in the current value of HEAD, in order to make sure we didn't clobber HEAD. In 55c4a67, that logic moved to validate_new_branchname(), which just resolves HEAD itself. The parameter to create_branch is now unused. Since we have to update and re-wrap the docstring describing the parameters anyway, let's take this opportunity to break it out into a list, which makes it easier to find the parameters. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0202c41 commit 4bd488e

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

branch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ N_("\n"
228228
"will track its remote counterpart, you may want to use\n"
229229
"\"git push -u\" to set the upstream config as you push.");
230230

231-
void create_branch(const char *head,
232-
const char *name, const char *start_name,
231+
void create_branch(const char *name, const char *start_name,
233232
int force, int reflog, int clobber_head,
234233
int quiet, enum branch_track track)
235234
{

branch.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
/* Functions for acting on the information about branches. */
55

66
/*
7-
* Creates a new branch, where head is the branch currently checked
8-
* out, name is the new branch name, start_name is the name of the
9-
* existing branch that the new branch should start from, force
10-
* enables overwriting an existing (non-head) branch, reflog creates a
11-
* reflog for the branch, and track causes the new branch to be
12-
* configured to merge the remote branch that start_name is a tracking
13-
* branch for (if any).
7+
* Creates a new branch, where:
8+
*
9+
* - name is the new branch name
10+
*
11+
* - start_name is the name of the existing branch that the new branch should
12+
* start from
13+
*
14+
* - force enables overwriting an existing (non-head) branch
15+
*
16+
* - reflog creates a reflog for the branch
17+
*
18+
* - track causes the new branch to be configured to merge the remote branch
19+
* that start_name is a tracking branch for (if any).
1420
*/
15-
void create_branch(const char *head, const char *name, const char *start_name,
21+
void create_branch(const char *name, const char *start_name,
1622
int force, int reflog,
1723
int clobber_head, int quiet, enum branch_track track);
1824

builtin/branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
807807
* create_branch takes care of setting up the tracking
808808
* info and making sure new_upstream is correct
809809
*/
810-
create_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
810+
create_branch(branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
811811
} else if (unset_upstream) {
812812
struct branch *branch = branch_get(argv[0]);
813813
struct strbuf buf = STRBUF_INIT;
@@ -853,7 +853,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
853853
strbuf_release(&buf);
854854

855855
branch_existed = ref_exists(branch->refname);
856-
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
856+
create_branch(argv[0], (argc == 2) ? argv[1] : head,
857857
force, reflog, 0, quiet, track);
858858

859859
/*

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
628628
}
629629
}
630630
else
631-
create_branch(old->name, opts->new_branch, new->name,
631+
create_branch(opts->new_branch, new->name,
632632
opts->new_branch_force ? 1 : 0,
633633
opts->new_branch_log,
634634
opts->new_branch_force ? 1 : 0,

0 commit comments

Comments
 (0)