git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	git@vger.kernel.org
Subject: [PATCH] branch: issue "-l" deprecation warning after pager starts
Date: Thu, 24 May 2018 15:31:05 -0400	[thread overview]
Message-ID: <20180524193105.GB21535@sigill.intra.peff.net> (raw)
In-Reply-To: <20180524192214.GA21535@sigill.intra.peff.net>

On Thu, May 24, 2018 at 03:22:14PM -0400, Jeff King wrote:

> On Thu, May 24, 2018 at 08:40:18PM +0530, Kaartic Sivaraam wrote:
> 
> > > On the other hand, I'm not sure this is that big a deal. The point of
> > > the deprecation warning is to catch people who are actually trying to
> > > use "-l" as "--create-reflog", and that case does not page. The people
> > > doing "git branch -l" are actually getting what they want eventually,
> > > which is to turn it into "--list". In the interim step where it becomes
> > > an unknown option, they'll get a hard error. 
> > 
> > I just thought we wouldn't want to surprise/confuse users who try to
> > use "git branch -l" with the warning message about "create reflog"
> > along-side the list of branches. That would just add to the confusion.
> > So, I thought we should error out when users do "git branch -l"
> > instead. Something like the following should help us prevent "git
> > branch -l" from listing branch names and might also prevent the
> > confusion.
> 
> Yeah, I think that's just a more extreme version of the current plan (it
> turns it immediately into a hard error instead of warning for a while).
> If we just make the warning easier to see in the paged case, I think
> that makes the current plan fine.
> 
> I'll wrap up the patch I sent earlier.

Hmm, actually, I suppose the true value of the warning is to help people
doing "git branch -l foo", and it would still work there. The "more
extreme" from your suggested patch would only affect "branch -l".

Still, I think I prefer the gentler version that we get by keeping it as
a warning even in the latter case.

Here's the patch. It goes on top of jk/branch-l-0-deprecation (and will
naturally conflict with the removal branch, but the resolution should be
obvious).

-- >8 --
Subject: [PATCH] branch: issue "-l" deprecation warning after pager starts

If you run "git branch -l", we issue a deprecation warning
that "-l" is probably not doing what you expect. But we do
so while parsing the options, which is _before_ we start the
pager. Depending on your pager settings, this means that the
warning may get totally overwritten by the pager.

Instead, let's delay the message until after we would have
started the pager. If we do page, then it will end up inside
the pager (since we redirect stderr). And if not (including
the case when you really did mean for "-l" to work as
"--create-reflog"), then it will still get shown on stderr.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/branch.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index e50a5a1680..55bfacd843 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -34,6 +34,7 @@ static const char * const builtin_branch_usage[] = {
 	NULL
 };
 
+static int used_deprecated_reflog_option;
 static const char *head;
 static struct object_id head_oid;
 
@@ -573,8 +574,7 @@ static int edit_branch_description(const char *branch_name)
 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");
+	used_deprecated_reflog_option = 1;
 	*(int *)opt->value = !unset;
 	return 0;
 }
@@ -700,6 +700,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 	if (list)
 		setup_auto_pager("branch", 1);
 
+	if (used_deprecated_reflog_option) {
+		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"));
-- 
2.17.0.1391.g6fdbf40724


  reply	other threads:[~2018-05-24 19:31 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17  6:01 What's cooking in git.git (May 2018, #02; Thu, 17) Junio C Hamano
2018-05-17  6:39 ` jk/branch-l-0-deprecation (was Re: What's cooking in git.git (May 2018, #02; Thu, 17)) Kaartic Sivaraam
2018-05-17  9:48   ` Ævar Arnfjörð Bjarmason
2018-05-17 11:00     ` Kaartic Sivaraam
2018-05-17 12:02       ` Ævar Arnfjörð Bjarmason
2018-05-17 13:36     ` Jeff King
2018-05-24 15:10       ` Kaartic Sivaraam
2018-05-24 19:22         ` Jeff King
2018-05-24 19:31           ` Jeff King [this message]
2018-05-25  1:55             ` [PATCH] branch: issue "-l" deprecation warning after pager starts Junio C Hamano
2018-05-25  2:40               ` Jeff King
2018-05-25  8:56                 ` Junio C Hamano
2018-05-25  9:14                   ` Junio C Hamano
2018-05-25 17:10                     ` Jeff King
2018-05-26  2:37                       ` Junio C Hamano
2018-05-25 21:00                     ` [RFC PATCH 0/3] usage: prefix all lines in `vreportf()`, not just the first Martin Ågren
2018-05-25 21:00                       ` [RFC PATCH 1/3] usage: extract `prefix_suffix_lines()` from `advise()` Martin Ågren
2018-05-28  8:27                         ` Junio C Hamano
2018-05-28 18:40                         ` Duy Nguyen
2018-05-29 21:33                           ` Jeff King
2018-05-29 21:39                         ` Jeff King
2018-05-30  1:42                           ` Junio C Hamano
2018-05-30  6:00                             ` Junio C Hamano
2018-05-30 10:26                               ` Martin Ågren
2018-05-31  6:07                                 ` Jeff King
2018-05-25 21:00                       ` [RFC PATCH 2/3] usage: prefix all lines in `vreportf()`, not just the first Martin Ågren
2018-05-28  9:25                         ` Junio C Hamano
2018-05-28 18:45                           ` Duy Nguyen
2018-05-28 21:45                             ` Junio C Hamano
2018-05-29  4:49                               ` Martin Ågren
2018-05-29  5:50                                 ` Junio C Hamano
2018-05-29 10:30                                   ` Martin Ågren
2018-05-29 12:08                                     ` Junio C Hamano
2018-05-29 15:50                                 ` Duy Nguyen
2018-05-30 10:19                                   ` Martin Ågren
2018-05-29 21:32                           ` Jeff King
2018-05-30 10:20                             ` Martin Ågren
2018-05-25 21:00                       ` [RFC PATCH 3/3] usage: translate the "error: "-prefix and others Martin Ågren
2018-05-26  2:32                   ` [PATCH] branch: issue "-l" deprecation warning after pager starts Junio C Hamano
2018-05-26  2:33                     ` Junio C Hamano
2018-05-29 21:20                     ` Jeff King
2018-05-29 21:21                       ` Jeff King
2018-05-30  2:48                         ` Junio C Hamano
2018-05-31  5:44                           ` Jeff King
2018-05-26 19:39                 ` Kaartic Sivaraam
2018-06-02  4:46                 ` Duy Nguyen
2018-06-02  8:10                   ` Jeff King
2018-05-26 18:45             ` Kaartic Sivaraam
2018-05-29 21:15               ` Jeff King
2018-05-30  2:52                 ` Junio C Hamano
2018-05-31  5:51                   ` Jeff King
2018-06-01  1:35                     ` Junio C Hamano
2018-05-31  5:52                   ` Kaartic.Sivaraam
2018-05-17 13:22 ` What's cooking in git.git (May 2018, #02; Thu, 17) Derrick Stolee
2018-05-17 18:20 ` Stefan Beller
2018-05-17 18:29   ` [PATCH 0/2] Reroll 2 last commits of sb/object-store-replace Stefan Beller
2018-05-17 18:29     ` [PATCH 1/2] object.c: free replace map in raw_object_store_clear Stefan Beller
2018-05-17 18:29     ` [PATCH 2/2] replace-object.c: remove the_repository from prepare_replace_object Stefan Beller
2018-05-17 18:40   ` [PATCH] merge-recursive: give notice when submodule commit gets fast-forwarded Stefan Beller
2018-05-18 19:43     ` [PATCH v2 0/1] rebased: inform about auto submodule ff Leif Middelschulte
2018-05-18 19:48     ` [PATCH v3 " Leif Middelschulte
2018-05-18 19:48       ` [PATCH 1/1] Inform about fast-forwarding of submodules during merge Leif Middelschulte
2018-05-18 21:25         ` Elijah Newren
2018-05-21  4:12           ` Junio C Hamano
2018-05-17 19:46   ` [PATCH 0/8] Reroll of sb/diff-color-move-more Stefan Beller
2018-05-17 19:46     ` [PATCH 1/8] xdiff/xdiff.h: remove unused flags Stefan Beller
2018-05-17 19:46     ` [PATCH 2/8] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2018-05-17 19:46     ` [PATCH 3/8] diff.c: do not pass diff options as keydata to hashmap Stefan Beller
2018-05-17 19:46     ` [PATCH 4/8] diff.c: adjust hash function signature to match hashmap expectation Stefan Beller
2018-05-17 19:46     ` [PATCH 5/8] diff.c: add a blocks mode for moved code detection Stefan Beller
2018-05-17 19:46     ` [PATCH 6/8] diff.c: decouple white space treatment from move detection algorithm Stefan Beller
2018-05-18  4:00       ` Simon Ruderich
2018-05-18 19:25         ` Stefan Beller
2018-05-17 19:46     ` [PATCH 7/8] diff.c: add --color-moved-ignore-space-delta option Stefan Beller
2018-05-17 19:46     ` [PATCH 8/8] diff: color-moved white space handling options imply color-moved Stefan Beller
2018-05-17 22:53     ` [PATCH 0/8] Reroll of sb/diff-color-move-more Jonathan Tan
2018-06-07 23:54     ` Jacob Keller
2018-05-17 22:36   ` What's cooking in git.git (May 2018, #02; Thu, 17) Junio C Hamano
2018-05-17 22:39     ` Stefan Beller
2018-05-17 22:56     ` Junio C Hamano
2018-05-17 22:58       ` Stefan Beller
2018-05-21  1:57 ` brian m. carlson
2018-05-21 17:36   ` Stefan Beller
2018-05-25 12:28 ` sb/submodule-move-nested breaks t7411 under GIT_FSMONITOR_TEST Ævar Arnfjörð Bjarmason
2018-05-25 17:27   ` Stefan Beller
2018-05-25 19:49   ` Stefan Beller
2018-09-06 12:31     ` Ævar Arnfjörð Bjarmason
2018-09-06 16:57       ` Stefan Beller
2018-09-06 19:03         ` Ben Peart
2018-09-06 20:14           ` Stefan Beller
2018-09-06 20:34             ` [PATCH] git-mv: allow submodules and fsmonitor to work together Stefan Beller
2018-09-10 15:58               ` Ben Peart
2018-09-10 16:29                 ` [PATCH v1] " Ben Peart
2018-09-10 17:07                   ` Stefan Beller
2018-09-10 19:38                     ` Ben Peart

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=20180524193105.GB21535@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kaartic.sivaraam@gmail.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).