Merge branch 'jk/branch-l-0-deprecation' into next
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Mar 2018 01:27:25 +0000 (18:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Mar 2018 01:27:25 +0000 (18:27 -0700)
The "-l" option in "git branch -l" is an unfortunate short-hand for
"--create-reflog", but many users, both old and new, somehow expect
it to be something else, perhaps "--list". This step deprecates
the short-hand and warns about the future removal of the it when it
is used.

* jk/branch-l-0-deprecation:
branch: deprecate "-l" option
t: switch "branch -l" to "branch --create-reflog"
t3200: unset core.logallrefupdates when testing reflog creation

1  2 
builtin/branch.c
diff --combined builtin/branch.c
index 5bd2a0dd4891ce0d42ad897c7b5fe0f66ca73be4,e50a5a1680080c7cec1ea689e7940bbaa2fead2c..0ac5e831f06694c48a2853cbe35ad2e33340ba16
@@@ -273,7 -273,7 +273,7 @@@ static int delete_branches(int argc, co
                               bname.buf,
                               (flags & REF_ISBROKEN) ? "broken"
                               : (flags & REF_ISSYMREF) ? target
 -                             : find_unique_abbrev(oid.hash, DEFAULT_ABBREV));
 +                             : find_unique_abbrev(&oid, DEFAULT_ABBREV));
                }
                delete_branch_config(bname.buf);
  
@@@ -570,6 -570,15 +570,15 @@@ static int edit_branch_description(cons
        return 0;
  }
  
+ static int deprecated_reflog_option_cb(const struct option *opt,
+                                      const char *arg, int unset)
+ {
+       warning("the '-l' alias for '--create-reflog' is deprecated;");
+       warning("it will be removed in a future version of Git");
+       *(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('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', "create-reflog", &reflog, N_("create the branch's reflog")),
+               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),