Merge branch 'jk/branch-l-1-repurpose'
authorJunio C Hamano <gitster@pobox.com>
Mon, 17 Sep 2018 20:53:50 +0000 (13:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Sep 2018 20:53:50 +0000 (13:53 -0700)
Updated plan to repurpose the "-l" option to "git branch".

* jk/branch-l-1-repurpose:
doc/git-branch: remove obsolete "-l" references
branch: make "-l" a synonym for "--list"

1  2 
Documentation/git-branch.txt
builtin/branch.c
index 9767b2b483dbe634db1a700e4b3529593f8189ec,73ca0532ead4403ec03550639a48f0bf3fcc48c5..bf5316ffa929a88aa98f5b3c7a892ee43638a098
@@@ -14,7 -14,7 +14,7 @@@ SYNOPSI
        [(--merged | --no-merged) [<commit>]]
        [--contains [<commit]] [--no-contains [<commit>]]
        [--points-at <object>] [--format=<format>] [<pattern>...]
- 'git branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
+ 'git branch' [--track | --no-track] [-f] <branchname> [<start-point>]
  'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
  'git branch' --unset-upstream [<branchname>]
  'git branch' (-m | -M) [<oldbranch>] <newbranch>
@@@ -100,8 -100,6 +100,6 @@@ OPTION
        The negated form `--no-create-reflog` only overrides an earlier
        `--create-reflog`, but currently does not negate the setting of
        `core.logAllRefUpdates`.
- +
- The `-l` option is a deprecated synonym for `--create-reflog`.
  
  -f::
  --force::
@@@ -156,14 -154,11 +154,11 @@@ This option is only applicable in non-v
  --all::
        List both remote-tracking branches and local branches.
  
+ -l::
  --list::
        List branches.  With optional `<pattern>...`, e.g. `git
        branch --list 'maint-*'`, list only the branches that match
        the pattern(s).
- +
- This should not be confused with `git branch -l <branchname>`,
- which creates a branch named `<branchname>` with a reflog.
- See `--create-reflog` above for details.
  
  -v::
  -vv::
@@@ -268,11 -263,10 +263,11 @@@ start-point is either a local or remote
        order of the value. You may use the --sort=<key> option
        multiple times, in which case the last key becomes the primary
        key. The keys supported are the same as those in `git
 -      for-each-ref`. Sort order defaults to sorting based on the
 +      for-each-ref`. Sort order defaults to the value configured for the
 +      `branch.sort` variable if exists, or to sorting based on the
        full refname (including `refs/...` prefix). This lists
        detached HEAD (if present) first, then local branches and
 -      finally remote-tracking branches.
 +      finally remote-tracking branches. See linkgit:git-config[1].
  
  
  --points-at <object>::
diff --combined builtin/branch.c
index bbd006aab4b4798b7e86530fe3562c753e879bc1,c1662e3db34cca697ceb85239b4a93ce0f36ce05..5b4d883e1f6f432ce07aed6ac86532c6d877a969
@@@ -22,7 -22,6 +22,7 @@@
  #include "wt-status.h"
  #include "ref-filter.h"
  #include "worktree.h"
 +#include "help.h"
  
  static const char * const builtin_branch_usage[] = {
        N_("git branch [<options>] [-r | -a] [--merged | --no-merged]"),
@@@ -37,7 -36,6 +37,6 @@@
  
  static const char *head;
  static struct object_id head_oid;
- static int used_deprecated_reflog_option;
  
  static int branch_use_color = -1;
  static char branch_colors[][COLOR_MAXLEN] = {
@@@ -57,31 -55,29 +56,31 @@@ enum color_branch 
        BRANCH_COLOR_UPSTREAM = 5
  };
  
 +static const char *color_branch_slots[] = {
 +      [BRANCH_COLOR_RESET]    = "reset",
 +      [BRANCH_COLOR_PLAIN]    = "plain",
 +      [BRANCH_COLOR_REMOTE]   = "remote",
 +      [BRANCH_COLOR_LOCAL]    = "local",
 +      [BRANCH_COLOR_CURRENT]  = "current",
 +      [BRANCH_COLOR_UPSTREAM] = "upstream",
 +};
 +
  static struct string_list output = STRING_LIST_INIT_DUP;
  static unsigned int colopts;
  
 -static int parse_branch_color_slot(const char *slot)
 -{
 -      if (!strcasecmp(slot, "plain"))
 -              return BRANCH_COLOR_PLAIN;
 -      if (!strcasecmp(slot, "reset"))
 -              return BRANCH_COLOR_RESET;
 -      if (!strcasecmp(slot, "remote"))
 -              return BRANCH_COLOR_REMOTE;
 -      if (!strcasecmp(slot, "local"))
 -              return BRANCH_COLOR_LOCAL;
 -      if (!strcasecmp(slot, "current"))
 -              return BRANCH_COLOR_CURRENT;
 -      if (!strcasecmp(slot, "upstream"))
 -              return BRANCH_COLOR_UPSTREAM;
 -      return -1;
 -}
 +define_list_config_array(color_branch_slots);
  
  static int git_branch_config(const char *var, const char *value, void *cb)
  {
        const char *slot_name;
 +      struct ref_sorting **sorting_tail = (struct ref_sorting **)cb;
 +
 +      if (!strcmp(var, "branch.sort")) {
 +              if (!value)
 +                      return config_error_nonbool(var);
 +              parse_ref_sorting(sorting_tail, value);
 +              return 0;
 +      }
  
        if (starts_with(var, "column."))
                return git_column_config(var, value, "branch", &colopts);
@@@ -90,7 -86,7 +89,7 @@@
                return 0;
        }
        if (skip_prefix(var, "color.branch.", &slot_name)) {
 -              int slot = parse_branch_color_slot(slot_name);
 +              int slot = LOOKUP_CONFIG(color_branch_slots, slot_name);
                if (slot < 0)
                        return 0;
                if (!value)
@@@ -130,8 -126,7 +129,8 @@@ static int branch_merged(int kind, cons
                    (reference_name = reference_name_to_free =
                     resolve_refdup(upstream, RESOLVE_REF_READING,
                                    &oid, NULL)) != NULL)
 -                      reference_rev = lookup_commit_reference(&oid);
 +                      reference_rev = lookup_commit_reference(the_repository,
 +                                                              &oid);
        }
        if (!reference_rev)
                reference_rev = head_rev;
@@@ -164,7 -159,7 +163,7 @@@ static int check_branch_commit(const ch
                               const struct object_id *oid, struct commit *head_rev,
                               int kinds, int force)
  {
 -      struct commit *rev = lookup_commit_reference(oid);
 +      struct commit *rev = lookup_commit_reference(the_repository, oid);
        if (!rev) {
                error(_("Couldn't look up commit object for '%s'"), refname);
                return -1;
@@@ -218,7 -213,7 +217,7 @@@ static int delete_branches(int argc, co
        }
  
        if (!force) {
 -              head_rev = lookup_commit_reference(&head_oid);
 +              head_rev = lookup_commit_reference(the_repository, &head_oid);
                if (!head_rev)
                        die(_("Couldn't look up commit object for HEAD"));
        }
@@@ -578,14 -573,6 +577,6 @@@ static int edit_branch_description(cons
        return 0;
  }
  
- static int deprecated_reflog_option_cb(const struct option *opt,
-                                      const char *arg, int unset)
- {
-       used_deprecated_reflog_option = 1;
-       *(int *)opt->value = !unset;
-       return 0;
- }
  int cmd_branch(int argc, const char **argv, const char *prefix)
  {
        int delete = 0, rename = 0, copy = 0, force = 0, list = 0;
                OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
                OPT_BIT('c', "copy", &copy, N_("copy a branch and its reflog"), 1),
                OPT_BIT('C', NULL, &copy, N_("copy a branch, even if target exists"), 2),
-               OPT_BOOL(0, "list", &list, N_("list branch names")),
+               OPT_BOOL('l', "list", &list, N_("list branch names")),
                OPT_BOOL(0, "create-reflog", &reflog, N_("create the branch's reflog")),
-               {
-                       OPTION_CALLBACK, 'l', NULL, &reflog, NULL,
-                       N_("deprecated synonym for --create-reflog"),
-                       PARSE_OPT_NOARG | PARSE_OPT_HIDDEN,
-                       deprecated_reflog_option_cb
-               },
                OPT_BOOL(0, "edit-description", &edit_description,
                         N_("edit the description for the branch")),
                OPT__FORCE(&force, N_("force creation, move/rename, deletion"), PARSE_OPT_NOCOMPLETE),
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_branch_usage, options);
  
 -      git_config(git_branch_config, NULL);
 +      git_config(git_branch_config, sorting_tail);
  
        track = git_branch_track;
  
        if (list)
                setup_auto_pager("branch", 1);
  
-       if (used_deprecated_reflog_option && !list) {
-               warning("the '-l' alias for '--create-reflog' is deprecated;");
-               warning("it will be removed in a future version of Git");
-       }
        if (delete) {
                if (!argc)
                        die(_("branch name required"));