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

Re: [PATCH/RFC] git.c: support "!!" aliases that do not move cwd

From
Jeff King <peff@peff.net>
Date
Oct 9, 2016, 20:58 UTC
Message-ID
<20161009205854.byq2wqgemtmwudfb@sigill.intra.peff.net>
In-Reply-To
<CACsJy8BpYYJmBm32YsQyuP58uhLE+sn8WdhiHyY6xzcqPVjMVQ@mail.gmail.com>
On Sun, Oct 09, 2016 at 06:32:38PM +0700, Duy Nguyen wrote:
Show 16 quoted lines
> > If you mean ambiguity between the old "alias.X" and the new "alias.X.*",
> > then yes, I think that's an unavoidable part of the transition.  IMHO,
> > the new should take precedence over the old, and people will gradually
> > move from one to the other.
> 
> Do we really need to treat this differently than
> 
> [alias]
>     d2u = !dos2unix
>     d2u = C:/cygwin/bin/dos3unix.exe
> 
> ?
> 
> Another similar case is one d2u (could be either old syntax or new) is
> defined in ~/.gitconfig and the other d2u in $GIT_DIR/config. In
> either case, the "latest" d2u definition wins.
Yeah, that's reasonable, too. So:
  [alias]
    d2u = "!dos2unix"
acts exactly as if:
  [alias "d2u"]
    command = dos2unix
    type = shell
was specified at that point, which is easy to understand.
Show 12 quoted lines
> > If you mean the ambiguity between alias.X.shell and alias.X.exec in your
> > example, the problem is that you have keys with overlapping meanings.
> > One solution is "don't do that" (so have a key like "cmd", and another
> > to select "shell or git-cmd", etc). Another is to define some rule, like
> > "last one wins" (so "exec" overrides "shell" in your example).
> [...]
> 
> Any suggestion? I suppose we can have _one_ key for the command. How
> to execute that command (exec, shell, nocd...) are boolean options.
> People can still write conflicting things. We have been nice so far,
> always dying when the user specify conflicting command line options.
> We could do the same here, I guess.

Having separate exec/shell boolean options just punts the overlap from the command key to those keys. If you have two mutually exclusive options, I think the best thing is a single option, like:

  type = <shell | exec | whatever>

and then it is obvious that a second appearance of "type" overrides an earlier one, by our usual "last one wins" convention. As opposed to:

  shell = true
  exec = true

where you have to understand the meaning of each option to know that "exec" overrides "shell".

-Peff
Previous: Duy NguyenNext: Junio C Hamano
Message 17 of 34 in “git.c: support "!!" aliases that do not move cwd”
  1. git.c: support "!!" aliases that do not move cwdNguyễn Thái Ngọc Duy, Oct 6, 2016
  2. Junio C HamanoOct 6, 2016
  3. Johannes SchindelinOct 7, 2016
  4. Duy NguyenOct 7, 2016
  5. Matthieu MoyOct 7, 2016
  6. Duy NguyenOct 7, 2016
  7. Johannes SchindelinOct 7, 2016
  8. Matthieu MoyOct 7, 2016
  9. Johannes SchindelinOct 7, 2016
  10. Jeff KingOct 7, 2016
  11. Johannes SixtOct 7, 2016
  12. Jeff KingOct 7, 2016
  13. Johannes SchindelinOct 8, 2016
  14. Jeff KingOct 9, 2016
  15. Jeff KingOct 9, 2016
  16. Duy NguyenOct 9, 2016
  17. Jeff KingOct 9, 2016
  18. Junio C HamanoOct 10, 2016
  19. Jeff KingOct 10, 2016
  20. Junio C HamanoOct 10, 2016
  21. Johannes SchindelinOct 11, 2016
  22. Duy NguyenOct 11, 2016
  23. Johannes SchindelinOct 11, 2016
  24. Jeff KingOct 11, 2016
  25. Duy NguyenOct 26, 2016
  26. Junio C HamanoOct 26, 2016
  27. Jakub NarębskiOct 7, 2016
  28. Johannes SchindelinOct 7, 2016
  29. Jakub NarębskiOct 7, 2016
  30. Duy NguyenOct 8, 2016
  31. SZEDER GáborOct 11, 2016
  32. Jakub NarębskiOct 11, 2016
  33. Jeff KingOct 6, 2016
  34. Jeff KingOct 6, 2016

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.