]> git.ipfire.org Git - thirdparty/git.git/commit
branch: deprecate "-l" option
authorJeff King <peff@peff.net>
Fri, 22 Jun 2018 09:24:14 +0000 (05:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Jun 2018 20:19:33 +0000 (13:19 -0700)
commit055930bc8960c303ece01d9a34740f25a2a6bba6
tree1513fb77c51654c3301dc375aae554f9903c253d
parent7687f19e939dd8c9a2a67ede31b019092f0a1ccf
branch: deprecate "-l" option

The "-l" option is short for "--create-reflog". This has
caused much confusion over the years. Most people expect it
to work as "--list", because that would match the other
"mode" options like -d/--delete and -m/--move, as well as
the similar -l/--list option of git-tag.

Adding to the confusion, using "-l" _appears_ to work as
"--list" in some cases:

  $ git branch -l
  * master

because the branch command defaults to listing (so even
trying to specify --list in the command above is redundant).
But that may bite the user later when they add a pattern,
like:

  $ git branch -l foo

which does not return an empty list, but in fact creates a
new branch (with a reflog, naturally) called "foo".

It's also probably quite uncommon for people to actually use
"-l" to create a reflog. Since 0bee591869 (Enable reflogs by
default in any repository with a working directory.,
2006-12-14), this is the default in non-bare repositories.
So it's rather unfortunate that the feature squats on the
short-and-sweet "-l" (which was only added in 3a4b3f269c
(Create/delete branch ref logs., 2006-05-19), meaning there
were only 7 months where it was actually useful).

Let's deprecate "-l" in hopes of eventually re-purposing it
to "--list".

Note that we issue the warning only when we're not in list
mode. This means that people for whom it works as a happy
accident, namely:

  $ git branch -l
  master

won't see the warning at all. And when we eventually switch
to it meaning "--list", that will just continue to work.

We do the issue the warning for these important cases:

  - when we are actually creating a branch, in case the user
    really did mean it as "--create-reflog"

  - when we are in some _other_ mode, like deletion. There
    the "-l" is a noop for now, but it will eventually
    conflict with any other mode request, and the user
    should be told that this is changing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-branch.txt
builtin/branch.c