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

Branch name tab expansion does not work with aliases #164

Closed
haacked opened this issue Nov 17, 2014 · 30 comments
Closed

Branch name tab expansion does not work with aliases #164

haacked opened this issue Nov 17, 2014 · 30 comments

Comments

@haacked
Copy link
Contributor

haacked commented Nov 17, 2014

I have the following alias in my .gitconfig (To test, I cleared out everything else so my gitconfig only contained the following).

[alias]
    co = checkout

A long time ago, Posh-Git tab expansion for branch names would work with this. But now it doesn't.

Expected: Given a repo with branches, git co x{tab} would expand a branch name that starts with "x"
Actual: Nothing happens.

@dahlbyk
Copy link
Owner

dahlbyk commented Nov 21, 2014

Which version? Alias expansion seems to be working for me?

alias-completion

@haacked
Copy link
Contributor Author

haacked commented Nov 21, 2014

Hmmm, I think you just reminded me to update the one we ship with GHfW. 😛 Let me double check and get back to this.

@ntwb
Copy link

ntwb commented Nov 21, 2014

As I was reading the original issue here I thought "I wish GHfW would ship more frequent POSH-Git updates" and ooh, there it is. ?

@dahlbyk
Copy link
Owner

dahlbyk commented May 14, 2015

Let me double check and get back to this.

@haacked since you mentioned this last month, are you still not seeing alias expansion?

@haacked
Copy link
Contributor Author

haacked commented Mar 2, 2016

I'm still not seeing it @dahlbyk. I just updated to the latest version too.

@dahlbyk
Copy link
Owner

dahlbyk commented Mar 3, 2016

Fascinating, still works for me. Are you seeing any $Errors? Glad to screen share and have a look.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 4, 2017

@haacked how about now? 😞

@rkeithhill
Copy link
Collaborator

Aliases work for me as well.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 6, 2017

Pretty sure @haacked is just trolling me. If someone else is able to reproduce, I'd love to know more about the environment.

@dahlbyk dahlbyk closed this as completed Feb 6, 2017
@haacked
Copy link
Contributor Author

haacked commented Feb 7, 2017

@dahlbyk sorry, we just updated Posh-Git in Desktop to master a week ago and I still get the problem.

Is there a command I could run that would tell you which version of Posh-Git is loaded in case I happen to have a rogue installation?

@rkeithhill
Copy link
Collaborator

Try Get-Module posh-git | Format-Table Version, ModuleBase

@haacked
Copy link
Contributor Author

haacked commented Feb 7, 2017

0.6.1.20160330

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 7, 2017

That is the old version. New version should be 0.7.0. We updated the version number on January 26th. A bit more than a week ago.

@haacked
Copy link
Contributor Author

haacked commented Feb 7, 2017

Ah, I might not have shipped the update to Posh-Git in Desktop yet.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 7, 2017

@haacked If you're going to ship a Desktop update of posh-git, hang tight for a few days so we can get 0.7 finalized.

I'd love a GIF or something of the config/behavior you're expecting to tab-complete that isn't. Can anyone else on the Desktop team repro what you're seeing?

@haacked
Copy link
Contributor Author

haacked commented Feb 15, 2017

@dahlbyk so here's what I did. I cleared out my .gitconfig to be just the following.

[alias]
    co = checkout

Then I ran the following set of commands...

image

So in the last part, I typed git co and then I hit the TAB key and I expected it to cycle through the branch names but it auto-completed with .\.git

@rkeithhill
Copy link
Collaborator

I can't repro this:

posh-git-tab-completion2

@haacked
Copy link
Contributor Author

haacked commented Feb 15, 2017

@rkeithhill I wonder if it's something with the way we load Posh-Git in GitHub Desktop. If you try it with GitHub Desktop, can you repro it?

@rkeithhill
Copy link
Collaborator

I will try that later tonight. Does it matter if I have git.exe already installed (from git-scm.com)?

@haacked
Copy link
Contributor Author

haacked commented Feb 15, 2017

I will try that later tonight. Does it matter if I have git.exe already installed (from git-scm.com)?

I don't think so. If you launch the shell from our shortcut (or from the app by hitting the ~ key) it'll use our Git. We use the .gitconfig from the same place though %UserProfile\.gitconfig.

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 16, 2017

I downloaded Windows for GitHub for a Windows 8 VM I have. It didn't come with posh-git 0.7.0 so I updated to 0.7.0. With that I can repro what you are seeing. Now let me see if I can figure out what is going on.

Also, we reorg'd the posh-git dir structure a bit so we'll need to work with ya on how to configure your AppData\Local\GitHub\PoshGit... dir.

BTW do you think that GitHub for Windows should always load the version of posh-git that comes with it or do you want the GH configured PowerShell console to automatically load a newer version of posh-git if it is found on the user's system?

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 16, 2017

OK seems to be failing a regex match because we are getting back two co aliases. If I try an alias that isn't duplicated, then it works:

2> git config --get-regexp alias\.co
alias.co checkout
alias.co checkout

I have one defined in my global config but I'm not sure where the other is coming from. It is not defined in the .git/config I'm working in.

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 16, 2017

Logged as #421. PR #422 addresses this issue.

Is GH4W defining the co alias somehow? If so, the problem could be mitigated if GH4W checked if the user already has the alias defined before creating it.

@haacked
Copy link
Contributor Author

haacked commented Feb 16, 2017

@rkeithhill thanks for figuring this out! In the short run, I'll just remove my local one. 😄

@rkeithhill
Copy link
Collaborator

@haacked BTW how does GH4W start PowerShell? Is it using a PS console file or just starting the PowerShell.exe process?

@haacked
Copy link
Contributor Author

haacked commented Feb 28, 2017

@haacked BTW how does GH4W start PowerShell? Is it using a PS console file or just starting the PowerShell.exe process?

We start the the PowerShell.exe process. We look in the following places for powershell.exe:

  • %PATH%
  • %SystemRoot%\System32
  • %SystemRoot%\System32\WindowsPowerShell\v1.0

If you have $GITHUB_PROFILE defined, we'll load that profile only (with these flags -NoProfile -File "$GITHUB_PROFILE") where $GITHUB_PROFILE is replaced with the path to your GitHub Profile file.

If you don't have $GITHUB_PROFILE defined, we'll use the following flag -File "PATH/TO/profile.example.ps1"

That way we load your $PROFILE if it exists and the example profile for PoshGit.

@rkeithhill
Copy link
Collaborator

Thanks for the explanation! Was a bit worried that the change in dir structure might mess up GH4W but since you're using profile.example.ps1 there shouldn't be any issues.

@haacked
Copy link
Contributor Author

haacked commented Feb 28, 2017

but since you're using profile.example.ps1 there shouldn't be any issues.

Except that I keep getting a warning now that

WARNING: posh-git's profile.example.ps1 will be removed in a future version. To avoid a change in behavior, copy its contents into your ....Microsoft.PowerShell_profile.ps1

😛

I guess our workaround could be that we could keep loading a private copy of profile.example.ps1 to make it easy for users.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 28, 2017

You should be using 0.7, which doesn't have that warning. 😜

But seriously, as of #444 you can hide the warning by calling profile.example.ps1 with choco as its first arg. (I would accept a PR that switches that to a proper parameter, if you care to make the hack not Chocolatey-specific.) Or just stop using profile.example.ps1 now in favor of something like:

Import-Module $env:github_posh_git\posh-git.psd1
Start-SshAgent -Quiet

For the record, profile.example.ps1 won't actually go away until everything* breaks in 1.0.

* not actually everything.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 28, 2017

And just now I am noticing the previous entries in the thread. Context helps.

If you don't have $GITHUB_PROFILE defined, we'll use the following flag -File "PATH/TO/profile.example.ps1"

My recommendation would be for you to start using a GitHub-specific "default profile" that could probably be a bit simpler/smarter than our profile.example.ps1 needs to be.

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

4 participants