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

Re: git 'new' alias

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Sep 5, 2011, 16:36 UTC
Message-ID
<vpqipp77xpb.fsf@bauges.imag.fr>
In-Reply-To
<20110901211747.GA16308@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
>   $ git config alias.one
>   !f() { r=$1; shift; echo $r@{1}..$r@{0} "$@"; }; f
(which, I've just discovered, should be written as
[alias]
        one = "!f() { r=$1; shift; echo $r@{1}..$r@{0} "$@"; }; f"
otherwise "git config" messes up with the ; in the line)
> which I think was the original intent (modulo me replacing "git log"
> with "echo" for debugging, of course).
The original intent was mis-specified ;-).
I think I originally made the alias to do

git new # give me new stuff on current branch git new origin/master # same, for origin/master

and tried to enrich it to allow
git new master --oneline
without thinking about what
git new --oneline

should do (and obviously, without really testing it, I guess I had one version of the alias allowing each senario, and none allowing all of them).

I now have this, which is really ugly in a config file, but does the DWIMery I want:

	new = "!f () { if echo \"$1\" | grep -q -e '^-' -e '^$'; then r=; else r=$1; shift; fi; git log $r@{1}..$r@{0} \"$@\"; } && f"
(this one has even been vaguely tested ;-) )
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “git 'new' alias”
  1. Thiago FarinaSep 1, 2011
  2. Matthieu MoySep 1, 2011
  3. Jeff KingSep 1, 2011
  4. Matthieu MoySep 5, 2011
  5. Jeff KingSep 5, 2011

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.