Modifying tab completion for files to be relative.#626
Modifying tab completion for files to be relative.#626cdonnellytx wants to merge 3 commits intodahlbyk:masterfrom
Conversation
|
Not sure how my changes are causing AppVeyor to fail on getting branches... will look into it later this week. |
|
I checked in a fix for the AppVeyor tests into master, if you want to rebase and try again. |
|
|
||
| &$gitbin config alias.$alias checkout | ||
| (&$gitbin config --get-all alias.$alias).Count | Should Be 1 | ||
| @(&$gitbin config --get-all alias.$alias).Count | Should Be 1 |
There was a problem hiding this comment.
This is not needed e.g. (1,2).count returns 2 , (1).count returns 1 and ($null).count returns 0.
There was a problem hiding this comment.
I'll go ahead and revert this. (The thing I was seeing was that it was resolving the expression as a single string and not an array...)
If you are in a subdirectory of a repo, tab-completion will now honor your current location.
Resolve-Path always renders files with a leading ".\" (Windows) or "./" (everything else). This differs from how paths were returned before, so now the tests are changing to reflect this. It is also now consistent with how tab completion works for other PowerShell commands (e.g., Get-ChildItem), so it shouldn't be a problem.
223d0d1 to
7bb89e4
Compare
|
OK, fixed. (I removed my attempt to fix CI from history entirely, which appears to have also hidden/deleted the GitHub discussion on that. Will be more mindful of that in the future and do a |
|
Overall looks good but @dahlbyk will do the final review. One thing I'm not 100% sure about is if a |
rkeithhill
left a comment
There was a problem hiding this comment.
LGTM other than the unnecessary [string].
|
@cdonnellytx Finally getting back around to this and in my testing (without this PR) I'm seeing dir relative paths. For instance, I modify a file in the |
|
@rkeithhill I'm seeing it on Steps to reproduce:
(EDIT: formatting) |
|
@cdonnellytx Sorry for the delay. What version of |
|
OK, so I figured it out... and it amounts to my forgetting something pretty major 🤦♂ : I had made a local change to the
This is what the change looked like in GitUtils.ps1: - $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch 2>$null }
+ $status = Invoke-Utf8ConsoleCommand { git status $untrackedFilesOption --porcelain --branch 2>$null }I meant to submit a PR for this change, but never got to it. But worse than that, what I did not realize was this:
In other words, the bug is something I introduced by using The good news, though, is that this will still work, since One other possibility is to use porcelain format v2, which does honor status.relativePaths and thus would not be as invasive a change. The only downside there is that may require raising the minimum version of Git that posh-git supports to 2.11.0 (commit). Thoughts? # Chris (EDIT: make things more obvious) |
|
Nice sleuthing. Thanks for taking the time to track that down!! RE using porcelain format v2, that's a question for @dahlbyk. |
We do require Git 2.15+ now, and I am considering using Anyway, thanks for trying to help…almost three years ago. 🤦♂️ |
|
No worries, it happens. |

Right now if you are in a subdirectory of a Git repository, and you attempt to tab complete a list of files, you get repo-relative paths.
This patch modifies the tab completion to get paths relative to your current path so that the paths can be used properly in git commands like
add.I ran the tests by hand (
gci -Filter '*.ps1' .\test\ | ForEach-Object { & $_.FullName }) and did not find any test differences from master.Please let me know if you need more information.
Thanks!
# Chris