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

Tab expansion starting with '#' needs to be escaped #293

Closed
Morten242 opened this issue Jun 28, 2016 · 7 comments
Closed

Tab expansion starting with '#' needs to be escaped #293

Morten242 opened this issue Jun 28, 2016 · 7 comments

Comments

@Morten242
Copy link

When using tab-expansion on branch-names, if they start with '#' then it, and the rest of the line will get ignored by powershell since '#' marks the start of a line comment. Escaping it with ` does help though, e.g.:

git checkout#1-branch-name
`

This is only necessary when the name starts with the pound-sign though, as names like feature/#1-branch-name works fine without any escaping.

@dahlbyk dahlbyk changed the title Expanding branch-names starting with '#' need to be escaped Tab expansion starting with '#' needs to be escaped Jan 4, 2017
@dahlbyk
Copy link
Owner

dahlbyk commented Jan 4, 2017

This applies to any string that starts with #. More generally, it seems like we would do well to have a generic "quote tab completed value" filter that handles any string that looks like PowerShell might get confused (e.g. stash refs).

For the record, you can either escape (`#branch) or quote ('#branch') these strings.

@rkeithhill
Copy link
Collaborator

Yup, # is a special char in PoweShell (comment). There are a number of special characters most of which are punctuation like $, @, (, {, ;.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 4, 2017

And Git supports branches starting with all of them:
image

@rkeithhill
Copy link
Collaborator

PowerShell will automatically quote paths during tab expansion that contain special chars or spaces. I'm guessing we could do something similar when tab expanding branch names. How about remote names? Can you have special chars in remote names as well?

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 6, 2017

Can you have special chars in remote names as well?

Yep. I'm inclined to add a guard against special characters in any tab completed string.

@rkeithhill
Copy link
Collaborator

@dahlbyk There are some tab completed strings that are already escaped via single quotes (stashes and TF shelvesets).

@lzybkr
Copy link
Collaborator

lzybkr commented Feb 13, 2017

@rkeithhill - I think I've solved this problem completely in TabExpansionPlusPlus, see https://github.com/lzybkr/TabExpansionPlusPlus/blob/master/TabExpansionPlusPlus.psm1#L64 - feel free to take that code as you see fit (I guess V3 and beyond only).

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