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 55c4a6730, 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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 4, 2016 at 12:30 UTC 4bd488ea7c56b673947b07511d26f2afc4ec0bd6
4 files changed +18 -13
branch.c
+1 -2
@@ -228,8 +228,7 @@ N_("\n"
228 "will track its remote counterpart, you may want to use\n"
229 "\"git push -u\" to set the upstream config as you push.");
230
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,
232 int force, int reflog, int clobber_head,
233 int quiet, enum branch_track track)
234 {
branch.h
+14 -8
@@ -4,15 +4,21 @@
4 /* Functions for acting on the information about branches. */
5
6 /*
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).
20 */
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,
22 int force, int reflog,
23 int clobber_head, int quiet, enum branch_track track);
24
builtin/branch.c
+2 -2
@@ -807,7 +807,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
807 * create_branch takes care of setting up the tracking
808 * info and making sure new_upstream is correct
809 */
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);
811 } else if (unset_upstream) {
812 struct branch *branch = branch_get(argv[0]);
813 struct strbuf buf = STRBUF_INIT;
@@ -853,7 +853,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
853 strbuf_release(&buf);
854
855 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,
857 force, reflog, 0, quiet, track);
858
859 /*
builtin/checkout.c
+1 -1
@@ -628,7 +628,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
628 }
629 }
630 else
631 - create_branch(old->name, opts->new_branch, new->name,
631 + create_branch(opts->new_branch, new->name,
632 opts->new_branch_force ? 1 : 0,
633 opts->new_branch_log,
634 opts->new_branch_force ? 1 : 0,