OSDN Git Service

branch: group related arguments of create_branch()
authorKaartic Sivaraam <kaartic.sivaraam@gmail.com>
Sat, 18 Nov 2017 17:26:46 +0000 (22:56 +0530)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Dec 2017 23:06:42 +0000 (15:06 -0800)
39bd6f726 (Allow checkout -B <current-branch> to update the current
branch, 2011-11-26) added 'clobber_head' (now, 'clobber_head_ok')
"before" 'track' as 'track' was closely related 'clobber_head' for
the purpose the commit wanted to achieve. Looking from the perspective
of how the arguments are used it turns out that 'clobber_head' is
more related to 'force' than it is to 'track'.

So, re-order the arguments to keep the related arguments close
to each other.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
branch.h
builtin/branch.c
builtin/checkout.c

index 3e8d2f9..bd607ae 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -228,7 +228,7 @@ N_("\n"
 "\"git push -u\" to set the upstream config as you push.");
 
 void create_branch(const char *name, const char *start_name,
-                  int force, int reflog, int clobber_head_ok,
+                  int force, int clobber_head_ok, int reflog,
                   int quiet, enum branch_track track)
 {
        struct commit *commit;
index cb6411f..f66536a 100644 (file)
--- a/branch.h
+++ b/branch.h
  *
  *   - force enables overwriting an existing (non-head) branch
  *
- *   - reflog creates a reflog for the branch
- *
  *   - clobber_head_ok allows the currently checked out (hence existing)
  *     branch to be overwritten; without 'force', it has no effect.
  *
+ *   - reflog creates a reflog for the branch
+ *
  *   - quiet suppresses tracking information
  *
  *   - track causes the new branch to be configured to merge the remote branch
  *     that start_name is a tracking branch for (if any).
+ *
  */
 void create_branch(const char *name, const char *start_name,
-                  int force, int reflog,
-                  int clobber_head_ok, int quiet, enum branch_track track);
+                  int force, int clobber_head_ok,
+                  int reflog, int quiet, enum branch_track track);
 
 /*
  * Validates that the requested branch may be created, returning the
index 33fd5fc..4edef5b 100644 (file)
@@ -806,7 +806,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                        die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));
 
                create_branch(argv[0], (argc == 2) ? argv[1] : head,
-                             force, reflog, 0, quiet, track);
+                             force, 0, reflog, quiet, track);
 
        } else
                usage_with_options(builtin_branch_usage, options);
index 7d8bcc3..6068f8d 100644 (file)
@@ -640,8 +640,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
                else
                        create_branch(opts->new_branch, new->name,
                                      opts->new_branch_force ? 1 : 0,
-                                     opts->new_branch_log,
                                      opts->new_branch_force ? 1 : 0,
+                                     opts->new_branch_log,
                                      opts->quiet,
                                      opts->track);
                new->name = opts->new_branch;