git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jacob Keller <jacob.keller@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Kaartic Sivaraam <kaartic.sivaraam@gmail.com>,
	Git mailing list <git@vger.kernel.org>
Subject: [PATCH 3/5] branch: deprecate "-l" option
Date: Mon, 26 Mar 2018 03:28:39 -0400	[thread overview]
Message-ID: <20180326072839.GC12530@sigill.intra.peff.net> (raw)
In-Reply-To: <20180326072505.GA12436@sigill.intra.peff.net>

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 dropping it
(it's a little too soon to repurpose it to "--list", but we
may even do that eventually).

Signed-off-by: Jeff King <peff@peff.net>
---
 Documentation/git-branch.txt |  3 ++-
 builtin/branch.c             | 17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index b3084c99c1..b959df1cbf 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -91,7 +91,6 @@ OPTIONS
 -D::
 	Shortcut for `--delete --force`.
 
--l::
 --create-reflog::
 	Create the branch's reflog.  This activates recording of
 	all changes made to the branch ref, enabling use of date
@@ -101,6 +100,8 @@ OPTIONS
 	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::
diff --git a/builtin/branch.c b/builtin/branch.c
index 6d0cea9d4b..e50a5a1680 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -570,6 +570,15 @@ static int edit_branch_description(const char *branch_name)
 	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;
@@ -612,7 +621,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		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),
-- 
2.17.0.rc1.509.g060626845b


  parent reply	other threads:[~2018-03-26  7:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-24 18:38 [PATCH] branch -l: print useful info whilst rebasing a non-local branch Kaartic Sivaraam
2018-03-25  1:34 ` Eric Sunshine
2018-03-25  3:41   ` Kaartic Sivaraam
2018-03-25  4:10     ` Jeff King
2018-03-25  4:13       ` Eric Sunshine
2018-03-25  4:28       ` Eric Sunshine
2018-03-25  4:33         ` Jeff King
2018-03-25  6:54           ` Kaartic Sivaraam
2018-03-25  7:15           ` Jacob Keller
2018-03-26  7:25             ` Jeff King
2018-03-26  7:26               ` [PATCH 1/5] t3200: unset core.logallrefupdates when testing reflog creation Jeff King
2018-03-26  7:26               ` [PATCH 2/5] t: switch "branch -l" to "branch --create-reflog" Jeff King
2018-03-26  7:28               ` Jeff King [this message]
2018-03-26  7:29               ` [PATCH 4/5] branch: drop deprecated "-l" option Jeff King
2018-03-26  7:29               ` [PATCH 5/5] branch: make "-l" a synonym for "--list" Jeff King
2018-03-26  7:44               ` [PATCH] branch -l: print useful info whilst rebasing a non-local branch Eric Sunshine
2018-03-26 18:38                 ` Jacob Keller
2018-03-25 17:06           ` Junio C Hamano
2018-03-25  5:48     ` Eric Sunshine
2018-03-25  7:36       ` Kaartic Sivaraam
2018-04-03  4:31 ` [PATCH v2 1/2] branch --list: print useful info whilst interactive rebasing a detached HEAD Kaartic Sivaraam
2018-04-03  4:31   ` [PATCH v2 2/2] t3200: verify "branch --list" sanity when rebasing from " Kaartic Sivaraam
2018-04-03  8:00     ` Eric Sunshine
2018-04-03 12:58       ` Kaartic Sivaraam
2018-04-03 14:47       ` [PATCH v3 " Kaartic Sivaraam
2018-04-04  8:09         ` Eric Sunshine
2018-04-03  5:02   ` [PATCH v2 0/2] branch --list: print useful info whilst interactive rebasing a " Kaartic Sivaraam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180326072839.GC12530@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.keller@gmail.com \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).