-
-
Notifications
You must be signed in to change notification settings - Fork 801
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
Case sensitivity with file paths #130
Comments
Interesting...never noticed that. I'd gladly accept a PR if you're able to fix this, otherwise it seems like something that we should be able to fix for free once I get around to pulling in LibGit2Sharp. |
How soon will that be? Perhaps this is a good Jump In tag issue in the meantime? |
Done :) |
Here is something that would work in powershell 3. Not sure how to do this in v2 yet, maybe proxy set-location? |
Is there a way you can resolve the path in posh-git before runing commands instead of trying to hook cd/set-location? For example, maybe you can call [System.IO.Directory]::SetCurrentDirectory with the case correct path before calling git. The PostCommandLookupHandler won't work in V2 and there are other cases you need to catch anyway, e.g. Push-Location and other custom cmdlets like Set-LocationEx (from PSCX) and Jump-Target. |
The challenge here is that posh-git doesn't actually intercept Rather than pretend the case is correct, maybe we should:
Thoughts? |
@dahlbyk I think suggestion 2 is fair. I'm not sure I understand what suggestion 1 is intended to do. |
Suggestion 1 is really just meant to provide a shortcut we can suggest be used to fix the casing, e.g. "Current path may confuse Git, which is case-sensitive. Use |
I'm assuming that calling reset-location as part of the prompt to make it transparent to the user is also more invasive than you want the default behavior to be? |
We could add a setting to auto-fix location (and mention it in the warning?), but with all the location-changing alternatives out there it seems better to have a conservative default. |
@dahlbyk I agree with being conservative in this case. I like "fix" better than "reset", so I'd suggest something like |
|
I should have thought of that. Perhaps |
|
Not sure why, but Optimize makes me chuckle. I suppose |
Have you considered creating a function 'git' that fixes the path before running git.exe? |
I haven't tried, but it's come up before as something that may open up some opportunities. I'm not sure what the best way to accurately forward the function's arguments on to |
So something more along the lines of the above commit is what you'd currently have in mind? I couldn't think of anything better for warning text, and there might already be a color I should have used from a setting rather than just hard coding "red". Also could have made the warning only appear when inside a git repository. |
That's pretty much exactly what I was thinking - open a PR? |
Will do. |
Not sure when this was fixed, but I can no longer reproduce this in git 2.10.2. |
ty |
Posh-git displays strange behavior if you navigate to a directory using the wrong case.
Imagine a directory called "code" with a subdirectory called "Model". The posh-git prompt is in code. User types "cd model" (all lower-case, so technically the incorrect case). PowerShell handles this fine and will show the prompt as "code\model", but if you do git status (for example) it will show any changes in the Model folder as "..\Model\changedfile.txt" instead of "changedfile.txt". This is technically correct if Git is assuming that both the model and Model directories exist. Other commands such as git mv OLD NEW, don't work at all as Git will warn that the file is not under source control.
Is there any way to get posh-git to intercept and fix cases on cd commands (or at least error/warn if a case is invalid)? I'm willing to look into this a bit if it sounds like this is something that you're interested to address. Thanks!
The text was updated successfully, but these errors were encountered: