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

Abbreviate Git Directory Edge Cases #746

Open
dahlbyk opened this issue Mar 16, 2020 · 8 comments
Open

Abbreviate Git Directory Edge Cases #746

dahlbyk opened this issue Mar 16, 2020 · 8 comments

Comments

@dahlbyk
Copy link
Owner

dahlbyk commented Mar 16, 2020

Two edge cases not considered by original implementation (#720):

  1. If the current repo is bare, returns its parent directory.
  2. Get-GitDirectory inside a worktree currently returns the path to .git/worktrees/[name], which won't match the current path. I can think of two ways to resolve this:
    1. Revise Get-GitDirectory to return the contents of .git/worktrees/[name]/gitdir. No idea what the downstream effects of this would be.
    2. Check here if $gitPath matches .git/worktrees/; if it does, set $gitPath to the contents of $gitPath/gitdir
@RexTremendae
Copy link

Submitted a PR (#797) to address nr 1 above.

I also found another thing which I don't really understand, Utils.ps1 line 288:
if (!$settings -or !$currentPath -or $currentPath.Equals($Home, $stringComparison))

This means that when in the home directory root, the path won't be abbreviated, this will only when I go down one or more levels. Isn't a more standard behavior to also abbreviate the home dir to only '~'?

@rkeithhill
Copy link
Collaborator

Isn't a more standard behavior to also abbreviate the home dir to only '~'?

On Linux yes but after using it on Windows, it seemed a bit too much of an abbreviation for the typical Windows user. We could qualify that last condition with a test for the OS so that we'd only do this on Windows. Alternatively, we could add a new setting for this that defaults differently for Windows.

@RexTremendae
Copy link

Alright, then I vote for a setting so that people who use both Windows and Linux can feel welcome at ~ :D

@rkeithhill
Copy link
Collaborator

After thinking about this some more, I'm really tempted to simplify and make Windows behave like Linux and just show ~ when in the home dir.

@dahlbyk
Copy link
Owner Author

dahlbyk commented Oct 19, 2020

Is it reasonable to default to whatever PowerShell defaults to without posh-git?

@rkeithhill
Copy link
Collaborator

Well, PowerShell does not abbreviate paths displayed in the prompt. Maybe we should not enable this option DefaultPromptAbbreviateHomeDirectory by default. And if the user does enable it, make it behave like a typical Linux prompt - always display ~ in place of the home path even when directly in the home path.

@dahlbyk
Copy link
Owner Author

dahlbyk commented Oct 19, 2020

And if the user does enable it, make it behave like a typical Linux prompt - always display ~ in place of the home path even when directly in the home path.

This matches Git Bash behavior, too.

@rkeithhill
Copy link
Collaborator

OK, I'll submit a PR to make this change later tonight!

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

3 participants