Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a way to define git function in git module #589

Closed
CircleCode opened this issue Apr 10, 2014 · 7 comments
Closed

add a way to define git function in git module #589

CircleCode opened this issue Apr 10, 2014 · 7 comments

Comments

@CircleCode
Copy link

In some cases, it can be useful to choose what script is designed by git, especially in git-info.
For example, I am using defunkt/hub which improves git features, and aliased it to git for commodity reasons. But hub is much slower than git, which is not perceptible in everyday use, but really visible in prompt module.

I'd love git module could call command git instead of git, but I'm not sure it has to be hard coded, then I suggest adding it as a configuration of git module.

@sorin-ionescu
Copy link
Owner

This is a known issue. See, #168, #242, #462, #507. While I can certainly change instances of git to command git, I can't do the same for the _git completion.

@CircleCode
Copy link
Author

Ok, sorry for the dupe.
Let me try a question: I see there have been some reflexions about a solution, and I am wondering if another approach is possible.

rather than aliasing git directly to hub, we may alias it to a script, and this script would determine (if possible) if we are in prompt generation. if yes, forward command to git, and if no, run hub

maybe this is stupid or not feasible, just wondering…

@CircleCode
Copy link
Author

additionnaly, this script could inspect funcstack to decide if hub has to be used

@CircleCode
Copy link
Author

my zsh skills are very low, but something like

if [[ ${funcstack[(i)_git]} -le ${#funcstack} ]] ; then
  command git "$@"
elif [[ ${funcstack[(i)git-info]} -le ${#funcstack} ]] ; then
  command git "$@"
else
  hub "$@"
fi

@sorin-ionescu
Copy link
Owner

That won't work. _git is a the completion function, a giant file that calls git all over the place. I would have to maintain my own version.

@CircleCode
Copy link
Author

Not sure I was clear.

The idea, here, is not to change git calls anywhere, since I understand
this is quite impossible.
Instead of this, I suggest to change the way git is aliased to hub:
instead of making git directly call hub, it would call a function
checking in funcstack if it is called from _git or git-info. If yes,
then the function would directly call git, if no, it would call hub.

@sorin-ionescu
Copy link
Owner

There are way too many functions of which to keep track. It's not reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants