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

Exclude detached HEAD "branch" from tab completion #367

Merged
merged 2 commits into from
Jan 16, 2017

Conversation

dahlbyk
Copy link
Owner

@dahlbyk dahlbyk commented Jan 16, 2017

When HEAD is detached, git branch includes a listing along the lines of (HEAD detached at deadbeef). This shouldn't be included when we're completing branch names.

@dahlbyk dahlbyk added this to the v0.7 milestone Jan 16, 2017
@@ -75,7 +75,7 @@ function script:gitBranches($filter, $includeHEAD = $false, $prefix = '') {
$prefix += $matches['from']
$filter = $matches['to']
}
$branches = @(git branch --no-color | ForEach-Object { if($_ -match "^\*?\s*(?<ref>.*)") { $matches['ref'] } }) +
$branches = @(git branch --no-color | ForEach-Object { if(!($_ -match "^\* \(HEAD detached .+\)$") -and ($_ -match "^\*?\s*(?<ref>.*)")) { $matches['ref'] } }) +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use -notmatch here otherwise looks good!

@dahlbyk dahlbyk merged commit feb50cf into master Jan 16, 2017
@dahlbyk dahlbyk deleted the branches-when-detached branch January 16, 2017 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants