git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Kaartic Sivaraam" <kaartic.sivaraam@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v2 3/4] branch: deprecate "-l" option
Date: Fri, 22 Jun 2018 18:43:50 -0400	[thread overview]
Message-ID: <20180622224349.GA7463@sigill.intra.peff.net> (raw)
In-Reply-To: <20180622223428.GA23440@flurp.local>

On Fri, Jun 22, 2018 at 06:34:28PM -0400, Eric Sunshine wrote:

> I wonder if it would be better and cleaner to limit the visibility of
> this change to cmd_branch(), rather than spreading it across a global
> variable, a callback function, and cmd_branch(). Perhaps, like this:

I'd prefer that, too, but...

> @@ -615,7 +616,9 @@ 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")),
> +		OPT_HIDDEN_BOOL('l', NULL, &deprecated_reflog_option,
> +				N_("deprecated synonym for --create-reflog")),

Now that "-l" processing is delayed, it interacts in a funny way with
--create-reflog. For instance:

  git branch -l --no-create-reflog

currently cancels itself out, but after your patch would enable reflogs.

This is a pretty niche corner case, but I think it's important not to
change any behavior during the deprecation period. You'd have to do
something more like:

  reflog = -1;

  ... parse options ...

  if (deprecated_reflog_option && !list)
    warning(...);
  if (reflog < 0 && deprecated_reflog_option)
    reflog = 1;

I think that probably works in all cases, but I actually think the
existing callback/global is less invasive.

-Peff

  reply	other threads:[~2018-06-22 22:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22  9:23 [PATCH v2 0/4] branch -l deprecation revisited Jeff King
2018-06-22  9:23 ` [PATCH v2 1/4] t3200: unset core.logallrefupdates when testing reflog creation Jeff King
2018-06-22  9:23 ` [PATCH v2 2/4] t: switch "branch -l" to "branch --create-reflog" Jeff King
2018-06-22  9:24 ` [PATCH v2 3/4] branch: deprecate "-l" option Jeff King
2018-06-22 22:34   ` Eric Sunshine
2018-06-22 22:43     ` Jeff King [this message]
2018-06-22  9:24 ` [PATCH v2 4/4] branch: make "-l" a synonym for "--list" Jeff King
2018-08-30  8:58   ` Ævar Arnfjörð Bjarmason
2018-08-30 18:48     ` Junio C Hamano
2018-08-30 19:53       ` Ævar Arnfjörð Bjarmason
2018-08-30 20:04         ` Jeff King
2018-08-30 20:29           ` Junio C Hamano
2018-08-30 20:50             ` Jeff King
2018-08-30 21:07               ` Ævar Arnfjörð Bjarmason

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

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

  git send-email \
    --in-reply-to=20180622224349.GA7463@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 \
    --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.
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 NNTP newsgroup(s).