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

Re: git-config: aliases with parameter expansion ($1 and such)

From
DSDirk Süsserott <newsletter@dirk.my1.cc>
Date
Mar 24, 2008, 13:15 UTC
Message-ID
<47E7A969.8010405@dirk.my1.cc>
In-Reply-To
<7vzlso3kjc.fsf@gitster.siamese.dyndns.org>
Thanks for the help. Both
    (1) atag = !sh -c 'git tag -a -m "$0" "$0"'
and
    (2) atag = !sh -c 'git tag -a -m "$1" "$1"' -
work, but in the latter case the '-' is indeed crucial.
If not given, $1 is not set and git tag complains badly.
When called without any args, (1) sets a tag called "sh"
whereas (2) complains about the missing value for the -m option.
So I decided to use the second form. Shells are funny things. ;-)
BTW: Is it true that "-a" is implicitely added to "git tag"
when the "-m" switch is present, i.e. are
    $ git tag -m foo foo
and
    $ git tag -a -m foo foo
equivalent? Thought so, but it's not in the docs.
Junio C Hamano schrieb:
Show 18 quoted lines
> "Jay Soffian" <jaysoffian@gmail.com> writes:
>
>   
>> All my shell aliases therefor look like:
>>
>> h          = "!sh -c 'git alias \"$1\" || git help \"$1\"' -"
>>
>> (Notice the trailing '-'.)
>>     
>
> Just for my curiosity, why aren't they
>
>   
>> h          = "!sh -c 'git alias \"$0\" || git help \"$0\"'"
>>     
>
> without trailing '-'?
>   
Previous: Junio C HamanoNext: Jeff King
Message 11 of 13 in “git-config: aliases with parameter expansion ($1 and such)”
  1. Dirk SüsserottMar 23, 2008
  2. Jay SoffianMar 23, 2008
  3. Dirk SüsserottMar 23, 2008
  4. Johannes SchindelinMar 23, 2008
  5. Dirk SüsserottMar 23, 2008
  6. Jeff KingMar 23, 2008
  7. Jeff KingMar 23, 2008
  8. Jeff KingMar 23, 2008
  9. Jay SoffianMar 24, 2008
  10. Junio C HamanoMar 24, 2008
  11. Dirk SüsserottMar 24, 2008
  12. Jeff KingMar 24, 2008
  13. Jay SoffianMar 24, 2008

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.