git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/4] branch: deprecate "-l" option

From
Jeff King <peff@peff.net>
Date
Jun 22, 2018, 22:43 UTC
Message-ID
<20180622224349.GA7463@sigill.intra.peff.net>
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...
Show 8 quoted lines
> @@ -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
Previous: Eric SunshineNext: Jeff King
Message 6 of 14 in “branch -l deprecation revisited”
  1. 0/4 branch -l deprecation revisitedJeff King, Jun 22, 2018
  2. 1/4 t3200: unset core.logallrefupdates when testing reflog creationJeff King, Jun 22, 2018
  3. 2/4 t: switch "branch -l" to "branch --create-reflog"Jeff King, Jun 22, 2018
  4. 3/4 branch: deprecate "-l" optionJeff King, Jun 22, 2018
  5. Eric SunshineJun 22, 2018
  6. Jeff KingJun 22, 2018
  7. 4/4 branch: make "-l" a synonym for "--list"Jeff King, Jun 22, 2018
  8. Ævar Arnfjörð BjarmasonAug 30, 2018
  9. Junio C HamanoAug 30, 2018
  10. Ævar Arnfjörð BjarmasonAug 30, 2018
  11. Jeff KingAug 30, 2018
  12. Junio C HamanoAug 30, 2018
  13. Jeff KingAug 30, 2018
  14. Ævar Arnfjörð BjarmasonAug 30, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.