From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:19
When an alias starts with an exclamation mark, the rest is interpreted
as a shell command. However, all arguments passed to git used to be
ignored.
Now you can have an alias like
$ git config alias.e '!echo'
and
$ git e Hello World
does what you expect it to do.
Signed-off-by: Johannes Schindelin <redacted>
---
I have this in my $HOME/.gitconfig:
[alias]
debug = !GIT_PAGER= gdb --args git
which allows me to debug, say "git log a..b" by saying "git debug
log a..b".
git.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
@@ -205,6 +205,21 @@ static int handle_alias(int *argcp, const char ***argv)git_config(git_alias_config);if(alias_string){if(alias_string[0]=='!'){+if(*argcp>1){+inti,sz=PATH_MAX;+char*s=xmalloc(sz),*new_alias=s;++add_to_string(&s,&sz,alias_string,0);+free(alias_string);+alias_string=new_alias;+for(i=1;i<*argcp&&+!add_to_string(&s,&sz," ",0)&&+!add_to_string(&s,&sz,(*argv)[i],1)+;i++)+;/* do nothing */+if(!sz)+die("Too many or long arguments");+}trace_printf("trace: alias to shell cmd: %s => %s\n",alias_command,alias_string+1);ret=system(alias_string+1);
On Sun, Jul 01, 2007 at 10:51:58PM +0100, Johannes Schindelin wrote:
When an alias starts with an exclamation mark, the rest is interpreted
as a shell command. However, all arguments passed to git used to be
ignored.
Now you can have an alias like
$ git config alias.e '!echo'
and
$ git e Hello World
does what you expect it to do.
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
- Ted
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:19
Hi,
On Mon, 2 Jul 2007, Theodore Tso wrote:
On Sun, Jul 01, 2007 at 10:51:58PM +0100, Johannes Schindelin wrote:
quoted
When an alias starts with an exclamation mark, the rest is interpreted
as a shell command. However, all arguments passed to git used to be
ignored.
Now you can have an alias like
$ git config alias.e '!echo'
and
$ git e Hello World
does what you expect it to do.
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
There is a point where you do not want to complicate git, but rather write
a script. This is such a point IMHO.
Ciao,
Dscho
On Mon, Jul 02, 2007 at 04:55:24PM +0100, Johannes Schindelin wrote:
quoted
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
There is a point where you do not want to complicate git, but rather write
a script. This is such a point IMHO.
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
Regards,
- Ted
From: Junio C Hamano <hidden> Date: 2016-06-15 22:43:19
Theodore Tso [off-list ref] writes:
On Mon, Jul 02, 2007 at 04:55:24PM +0100, Johannes Schindelin wrote:
quoted
quoted
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
There is a point where you do not want to complicate git, but rather write
a script. This is such a point IMHO.
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
That actually sounds sensible, but you could alias
!sh -c 'command $2 $1 $3'
to reorder the parameters, couldn't you?
On Mon, Jul 02, 2007 at 04:11:21PM -0700, Junio C Hamano wrote:
quoted
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
That actually sounds sensible, but you could alias
!sh -c 'command $2 $1 $3'
to reorder the parameters, couldn't you?
Um, how would that work on the Windows platform?
(I'm assuming here that we are trying to support Windows better, since
there are projects such as Mozilla, and MySQL that care very much
about first class Windows support. We could say this isn't important
enough, and that would be fine; but I wanted to at least raise the
question.)
- Ted
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:19
Hi,
On Mon, 2 Jul 2007, Theodore Tso wrote:
On Mon, Jul 02, 2007 at 04:11:21PM -0700, Junio C Hamano wrote:
quoted
quoted
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
That actually sounds sensible, but you could alias
!sh -c 'command $2 $1 $3'
to reorder the parameters, couldn't you?
Um, how would that work on the Windows platform?
(I'm assuming here that we are trying to support Windows better, since
there are projects such as Mozilla, and MySQL that care very much
about first class Windows support. We could say this isn't important
enough, and that would be fine; but I wanted to at least raise the
question.)
Windows support for those people unwilling to use cygwin amounts to
anything, but a command line interface. Since aliases are _bound_ to
the command line, I do not really get your point here.
In my view of things, for Windows support it is first of all important to
get rid of the dependency on bash in the core parts. Then we should
continue on the work Han-Wen did with his gub, and produce a proper
Windows-clicky-style installer which installs git-gui with a proper
Windows Start Menu item. But of course, then we should brace ourselves for
a lot of clueless^Winterested users.
Ciao,
Dscho
From: Alex Riesen <hidden> Date: 2016-06-15 22:43:19
On 7/2/07, Theodore Tso [off-list ref] wrote:
On Mon, Jul 02, 2007 at 04:55:24PM +0100, Johannes Schindelin wrote:
quoted
quoted
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
There is a point where you do not want to complicate git, but rather write
a script. This is such a point IMHO.
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
I don't think it is _possible_ to make it work on Windows properly: you have
to quote the arguments with whitespaces as there is nothing like argv there
(windows programs don't use command line, so it does not exist).
As the quoting is implemented in the programs the rules are all different
and mostly suboptimal.
From: Johannes Sixt <hidden> Date: 2016-06-15 22:43:19
Theodore Tso wrote:
On Mon, Jul 02, 2007 at 04:11:21PM -0700, Junio C Hamano wrote:
quoted
quoted
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
That actually sounds sensible, but you could alias
!sh -c 'command $2 $1 $3'
to reorder the parameters, couldn't you?
Um, how would that work on the Windows platform?
Shouldn't be a problem for Cygwin users, nor for MinGW port users. The
latter need a Bourne shell anyway for the various scripted git tools.
-- Hannes
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:43:19
Hi,
On Tue, 3 Jul 2007, Alex Riesen wrote:
On 7/2/07, Theodore Tso [off-list ref] wrote:
quoted
On Mon, Jul 02, 2007 at 04:55:24PM +0100, Johannes Schindelin wrote:
quoted
quoted
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
There is a point where you do not want to complicate git, but rather
write
quoted
a script. This is such a point IMHO.
Such a point exists, I agree, but I would draw after $* and $1/$2/$3
interpolation. There is a lot more value that gets added with
positional arguments support, and it makes git aliases more usable on
platforms such as Windows where scripting capability is much more
limited.
I don't think it is _possible_ to make it work on Windows properly: you have
to quote the arguments with whitespaces as there is nothing like argv there
(windows programs don't use command line, so it does not exist).
Since the "!" aliases use system() (i.e. no argv, but a plain string as
parameter), my patch already does that. It quotes the arguments properly.
As the quoting is implemented in the programs the rules are all different
and mostly suboptimal.
You mean the programs that could be called via "!" aliases? Yes, that is
right. And there is also the problem that you have to convert path names
if you are working on Windows, because of this c:\&@!§$ braindamage.
However, in this case Junio's idea to use the shell to do the hard work is
again an alternative:
[alias]
alex = !sh -c 'd:\program.exe $(cygpath -w "$1")'
FWIW I do not think that executing the shell from time to time is a big
problem. It's only that I would like to get rid of the dependency on perl
and bash for the plain Windows user, who will not dare to leave the gui
into the command line jungle where there be bisons, yaccs and kills.
Ciao,
Dscho
On Tue, Jul 03, 2007 at 02:37:43AM +0100, Johannes Schindelin wrote:
Windows support for those people unwilling to use cygwin amounts to
anything, but a command line interface. Since aliases are _bound_ to
the command line, I do not really get your point here.
You're right of course. <small>Never mind...</small>
- Ted