Skip to contentSkip to conversation

git silently ignores aliases of existing commands

DISCUSSION Michael G Schwern 5 participants 9 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

Signature · 4 lines
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/
#1 lore raw

On Fri, 17 Jul 2009 17:52:49 -0700
Michael G Schwern <[email protected]> wrote:

[...]

Quoted 4 lines

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.

[...]

Quoted 4 lines

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

#2 lore raw
Quoted 12 lines · Sean Estabrooks

On Fri, 17 Jul 2009 17:52:49 -0700
Michael G Schwern <[email protected]> wrote:

[...]

Quoted 4 lines

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:

Quoted 7 lines

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?

Signature · 3 lines
<Schwern> What we learned was if you get confused, grab someone and swing
          them around a few times
        -- Life's lessons from square dancing
#3 lore raw

2009/7/18 Michael G Schwern <[email protected]>:

Quoted 21 lines
Quoted 12 lines · Sean Estabrooks

On Fri, 17 Jul 2009 17:52:49 -0700
Michael G Schwern <[email protected]> wrote:

[...]

Quoted 4 lines

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:

Quoted 7 lines

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.

Quoted 4 lines

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

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#4 lore raw
Quoted 2 lines · demerphq

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");
Quoted 2 lines

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

#5 lore raw

2009/7/18 Jeff King <[email protected]>:

Quoted 15 lines · demerphq
Quoted 3 lines

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");

Quoted 7 lines
Quoted 2 lines

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

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#6 lore raw
Quoted 7 lines · demerphq
Quoted 4 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

#7 lore raw

2009/7/18 Jeff King <[email protected]>:

Quoted 15 lines · demerphq
Quoted 8 lines
Quoted 5 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.

Quoted 7 lines

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

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#8 lore raw
Quoted 25 lines · demerphq

2009/7/18 Jeff King <[email protected]>:

Quoted 13 lines · demerphq
Quoted 7 lines
Quoted 5 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.

Quoted 7 lines

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.

Quoted 8 lines

:-)

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.