threads / patch / 22239

patchDocumentation: explain how to write aliases that use other aliases

Subject: [PATCH] Documentation: explain how to write aliases that use other aliases

## tl;dr

One message between Jan 16, 2010 and Jan 16, 2010. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Eric James Michael Ritz· Jan 16, 2010, 01:42 UTC · lore
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Users who try to define aliases in terms of other aliases will receive an error about an unrecognized command. This is because Git only applies alias expansion once. However, users can write aliases with the exclamation point prefix to achieve this effect. Teach users how to do this by building off the example of using aliases to call shell commands.

Signed-off-by: Eric James Michael Ritz <Eric@cybersprocket.com>
- ---
I ran into this issue try to define some aliases, and then after an
hour of hacking on alias.c a light-bulb went off in my head, and I
realized I could just use the '!' prefix to write aliases that call
other aliases.  Much simplier than the alias code I was changing, lol.
So I thought it would be useful to mention this in the manual, for
users like myself who like to build aliases from other aliases.
 Documentation/config.txt |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Show changes to Documentation/config.txt +6 −4
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 8acb613..0874a0d 100644
- --- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -524,7 +524,12 @@ If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
 "alias.new = !gitk --all --not ORIG_HEAD", the invocation
 "git new" is equivalent to running the shell command
- -"gitk --all --not ORIG_HEAD".  Note that shell commands will be
+"gitk --all --not ORIG_HEAD".  Git will not expand aliases which
+call other aliases,  but you can use the exclamation point prefix to
+achieve this effect.  For example, defining "alias.today =
+!git new --since=yesterday" will cause "git today"
+to expand to "gitk --all --not ORIG_HEAD --since=yesterday".
+Note that shell commands will be
 executed from the top-level directory of a repository, which may
 not necessarily be the current directory.

- --
1.6.6.159.g8802c



- -- 
Eric Ritz
Cyber Sprocket Labs
(843) 225-3830
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLURmKAAoJEEHUZXw5hMWsCZoIALh+tvIJHNVVQtPr1xOEtuYg
fGh4GUdDOwzsWekbxoUpzFwaE0zteawIlG7QYrLKkuFtR4E3bziM86HpIZ4nIy8b
wnZzFVSEGfhAIkhxICsSWFDZp1R0tUN5+i5NOhIrMC0nnQ0aM36Ruzyt1GbntkH1
uBsO9NYpoP+a4HQRGtafXNg2jBC1PoWy3UWTpETsIUHlV3CTrAr17uVbSDt0QSK+
lfhD717w88mvfewJaNwqnrXskADmE+bYbQBr2dvUAutbcRKx0+HREz3ju+/oTtfN
nGaSOX/kLUfTIR4+aGz6u2bkfaGt8WDBibGnC1d0l/c9jxvlodOBZxWcFscxZ4A=
=Divy
-----END PGP SIGNATURE-----

← back to recent threads