threads / discuss / 20149

git silently ignores aliases of existing commands

Subject: git silently ignores aliases of existing commands

## tl;dr

9 messages between Jul 18, 2009 and Jul 18, 2009.

replies: 8people: 5as markdown or json

Michael G Schwern· Jul 18, 2009, 00:52 UTC · lore

Everyone says "git tag" does the wrong thing by default and what you really want is an annotated tag with "git tag -a". So I figured I'd fix the default and in my .gitconfig added:

[alias]
    tag = tag -a

and considered it done. Weeks later I discovered git was ignoring that alias and I was still making lightweight tags.

It would be nice if git used the alias *before* the installed command. This lets me fix/change default behaviors without having to come up with a new command. (Another handy example: blame = blame -w) It doesn't do anything useful right now anyway.

Whether or not that changes, if an alias is being ignored git should warn me.
 This informs the user their perfectly sensible action has not done what they
expected.  In addition, should git add a command in the future which conflicts
with the name of an alias they'll know.

PS I couldn't find anything obvious about where to send bug reports / feature requests in the git man page, just "general upbringing" pointing here. It would be helpful if it was a bit more clear. None of "bug", "report" or "issue" pointed at anything relevant.

-- 
184. When operating a military vehicle I may *not* attempt something
     "I saw in a cartoon".
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/
Sean Estabrooks· Jul 18, 2009, 02:01 UTC · re: Michael G Schwern · lore

Re: git silently ignores aliases of existing commands

On Fri, 17 Jul 2009 17:52:49 -0700 Michael G Schwern <schwern@pobox.com> wrote:

[...]
> It would be nice if git used the alias *before* the installed command.  This
> lets me fix/change default behaviors without having to come up with a new
> command.  (Another handy example:  blame = blame -w)  It doesn't do anything
> useful right now anyway.
Hi Michael,

This has been discussed a few times on the list already. Here is one such discussion:

http://thread.gmane.org/gmane.comp.version-control.git/112487/focus=112493

You'll see that it was decided that Git would not allow commands to be overridden so that you could always be sure what a given command would do when you sit down at any installation. This is especially important for scripting but can also be a problem for everyday usage. You'll just have to choose a new command name for the alternate default you want.

[...]
> PS  I couldn't find anything obvious about where to send bug reports / feature
> requests in the git man page, just "general upbringing" pointing here.  It
> would be helpful if it was a bit more clear.  None of "bug", "report" or
> "issue" pointed at anything relevant.
This list is the appropriate place for any of the issues you enumerate.

Cheers, Sean

Michael G Schwern· Jul 18, 2009, 07:16 UTC · re: Sean Estabrooks · lore

Re: git silently ignores aliases of existing commands

Sean Estabrooks wrote:
Show 19 quoted lines
> On Fri, 17 Jul 2009 17:52:49 -0700
> Michael G Schwern <schwern@pobox.com> wrote:
> 
> [...]
>> It would be nice if git used the alias *before* the installed command.  This
>> lets me fix/change default behaviors without having to come up with a new
>> command.  (Another handy example:  blame = blame -w)  It doesn't do anything
>> useful right now anyway.
> 
> This has been discussed a few times on the list already.   Here is one such
> discussion:
> 
> http://thread.gmane.org/gmane.comp.version-control.git/112487/focus=112493
> 
> You'll see that it was decided that Git would not allow commands to be overridden
> so that you could always be sure what a given command would do when you sit
> down at any installation.  This is especially important for scripting but can
> also be a problem for everyday usage.   You'll just have to choose a new command
> name for the alternate default you want.
I'm in the "more than enough rope" camp myself, so count that as a -1 fwiw.

More importantly, what about the warning telling the user that what they did is not allowed and didn't work?

-- 
<Schwern> What we learned was if you get confused, grab someone and swing
          them around a few times
        -- Life's lessons from square dancing
demerphq· Jul 18, 2009, 09:30 UTC · re: Michael G Schwern · lore

Re: git silently ignores aliases of existing commands

2009/7/18 Michael G Schwern <schwern@pobox.com>:
Show 25 quoted lines
> Sean Estabrooks wrote:
>> On Fri, 17 Jul 2009 17:52:49 -0700
>> Michael G Schwern <schwern@pobox.com> wrote:
>>
>> [...]
>>> It would be nice if git used the alias *before* the installed command.  This
>>> lets me fix/change default behaviors without having to come up with a new
>>> command.  (Another handy example:  blame = blame -w)  It doesn't do anything
>>> useful right now anyway.
>>
>> This has been discussed a few times on the list already.   Here is one such
>> discussion:
>>
>> http://thread.gmane.org/gmane.comp.version-control.git/112487/focus=112493
>>
>> You'll see that it was decided that Git would not allow commands to be overridden
>> so that you could always be sure what a given command would do when you sit
>> down at any installation.  This is especially important for scripting but can
>> also be a problem for everyday usage.   You'll just have to choose a new command
>> name for the alternate default you want.
>
> I'm in the "more than enough rope" camp myself, so count that as a -1 fwiw.
>
> More importantly, what about the warning telling the user that what they did
> is not allowed and didn't work?

Yeah it seems reasonable that if its going to be ignored it should not be silently ignored.

Especially given that the silentness effectively means there cant be any new git tools added without possible breakage of installed setups.

cheers, Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Jeff King· Jul 18, 2009, 10:46 UTC · re: demerphq · lore

Re: git silently ignores aliases of existing commands

On Sat, Jul 18, 2009 at 11:30:25AM +0200, demerphq wrote:
> Yeah it seems reasonable that if its going to be ignored it should not
> be silently ignored.

I agree that there should be a warning. However, it's hard to do with the code structured as it is now; we don't know that a command exists as an external command until we try to exec it. And if it succeeds, we don't get to execute any more code.

It's certainly possible, but sadly it is more surgery than just
  if (alias_lookup(cmd))
    warn("you also have an alias defined");
> Especially given that the silentness effectively means there cant be
> any new git tools added without possible breakage of installed setups.

The silentness makes it harder to diagnose problems, but even with a warning, we can break things by creating new commands. If you have an alias "foo" and we ship "git-foo" in a newer version of git, your alias will just stop working.

-Peff
demerphq· Jul 18, 2009, 10:55 UTC · re: Jeff King · lore

Re: git silently ignores aliases of existing commands

2009/7/18 Jeff King <peff@peff.net>:
Show 22 quoted lines
> On Sat, Jul 18, 2009 at 11:30:25AM +0200, demerphq wrote:
>
>> Yeah it seems reasonable that if its going to be ignored it should not
>> be silently ignored.
>
> I agree that there should be a warning. However, it's hard to do with
> the code structured as it is now; we don't know that a command exists
> as an external command until we try to exec it. And if it succeeds, we
> don't get to execute any more code.
>
> It's certainly possible, but sadly it is more surgery than just
>
>  if (alias_lookup(cmd))
>    warn("you also have an alias defined");
>
>> Especially given that the silentness effectively means there cant be
>> any new git tools added without possible breakage of installed setups.
>
> The silentness makes it harder to diagnose problems, but even with a
> warning, we can break things by creating new commands. If you have an
> alias "foo" and we ship "git-foo" in a newer version of git, your alias
> will just stop working.

That was my point. At least if there were warnings about this the risk would be mitigated.

cheers, Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Jeff King· Jul 18, 2009, 10:58 UTC · re: demerphq · lore

Re: git silently ignores aliases of existing commands

On Sat, Jul 18, 2009 at 12:55:26PM +0200, demerphq wrote:
Show 7 quoted lines
> > The silentness makes it harder to diagnose problems, but even with a
> > warning, we can break things by creating new commands. If you have an
> > alias "foo" and we ship "git-foo" in a newer version of git, your alias
> > will just stop working.
> 
> That was my point. At least if there were warnings about this the risk
> would be mitigated.

I don't see how it's mitigated. You don't get any warning until _after_ things are broken. So yes, it may help you diagnose the breakage, but presumably the fact that the command is doing something completely different would also alert you to the breakage.

The real problem comes from scripted use, where you don't necessarily have a user reading warnings on stderr, or notice that some totally bogus code is being run (especially if said code happens not to produce a non-zero exit code).

But perhaps that's what you meant, and I'm just nitpicking your language.

-Peff
demerphq· Jul 18, 2009, 11:20 UTC · re: Jeff King · lore

Re: git silently ignores aliases of existing commands

2009/7/18 Jeff King <peff@peff.net>:
Show 22 quoted lines
> On Sat, Jul 18, 2009 at 12:55:26PM +0200, demerphq wrote:
>
>> > The silentness makes it harder to diagnose problems, but even with a
>> > warning, we can break things by creating new commands. If you have an
>> > alias "foo" and we ship "git-foo" in a newer version of git, your alias
>> > will just stop working.
>>
>> That was my point. At least if there were warnings about this the risk
>> would be mitigated.
>
> I don't see how it's mitigated. You don't get any warning until _after_
> things are broken. So yes, it may help you diagnose the breakage, but
> presumably the fact that the command is doing something completely
> different would also alert you to the breakage.
>
> The real problem comes from scripted use, where you don't necessarily
> have a user reading warnings on stderr, or notice that some totally
> bogus code is being run (especially if said code happens not to produce
> a non-zero exit code).
>
> But perhaps that's what you meant, and I'm just nitpicking your
> language.

I think we are more or less in agreement, except maybe that i think the situation would be marginally better if git detected this.

:-)

Seems an awkward position actually. Maybe a switch like --ignore-command-aliases which would be used by all internal commands when they expect to find another internal command would resolve it. Then aliases of internal commands to control default switches could actually be allowed to work, and there would not be the future compatibility trap that there seems to be now.

cheers, Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
A Large Angry SCM· Jul 18, 2009, 16:12 UTC · re: demerphq · lore

Re: git silently ignores aliases of existing commands

demerphq wrote:
Show 33 quoted lines
> 2009/7/18 Jeff King <peff@peff.net>:
>> On Sat, Jul 18, 2009 at 12:55:26PM +0200, demerphq wrote:
>>
>>>> The silentness makes it harder to diagnose problems, but even with a
>>>> warning, we can break things by creating new commands. If you have an
>>>> alias "foo" and we ship "git-foo" in a newer version of git, your alias
>>>> will just stop working.
>>> That was my point. At least if there were warnings about this the risk
>>> would be mitigated.
>> I don't see how it's mitigated. You don't get any warning until _after_
>> things are broken. So yes, it may help you diagnose the breakage, but
>> presumably the fact that the command is doing something completely
>> different would also alert you to the breakage.
>>
>> The real problem comes from scripted use, where you don't necessarily
>> have a user reading warnings on stderr, or notice that some totally
>> bogus code is being run (especially if said code happens not to produce
>> a non-zero exit code).
>>
>> But perhaps that's what you meant, and I'm just nitpicking your
>> language.
> 
> I think we are more or less in agreement, except maybe that i think
> the situation would be marginally better if git detected this.
> 
> :-)
> 
> Seems an awkward position actually. Maybe a switch like
> --ignore-command-aliases which would be used by all internal commands
> when they expect to find another internal command would resolve it.
> Then aliases of internal commands to control default switches could
> actually be allowed to work, and there would not be the future
> compatibility trap that there seems to be now.
The real solution is to (re)move the aliases from the git name-space.

← back to recent threads