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

fish git prompt ignores untracked files above current directory #6086

Closed
marcvangend opened this issue Sep 2, 2019 · 6 comments
Closed

fish git prompt ignores untracked files above current directory #6086

marcvangend opened this issue Sep 2, 2019 · 6 comments

Comments

@marcvangend
Copy link

Hi all, thanks for your work on fish-shell. I'm using fish (version 3.0.2) on MacOS (10.14.6) in an Iterm2 (build 3.3.2) terminal. Using fish_config I have selected the "Informative Vcs" prompt.

I am not sure if this is considered a bug, but at least I'm wondering why the fish git prompt does not always show that untracked files are present. To be precise: the "untrackedfiles" character () only appears in the prompt when untracked files are present in or below the current directory. When untracked files are present above the current directory (off course still within the same git repo) the git prompt seems to ignore them.

This behavior seems to be caused by the __fish_git_prompt_informative_status command. By contrast, the __fish_git_prompt_untracked command always returns the expected value.

To illustrate what I mean, I made this screenshot reproducing the issue:
Screenshot 2019-09-02 at 11 11 00
As you can see, file.txt is untracked, but once you descend into the "sub" directory, the prompt shows the "cleanstate" check mark even though __fish_git_prompt_untracked recognizes the presence of an untracked file.

I also tested this without third-party customizations (sh -c 'env HOME=$(mktemp -d) fish'), with the "Informative Vcs" prompt as only customization. The same behavior occurred.

@zanchey
Copy link
Member

zanchey commented Sep 2, 2019

This behaviour was copied from the Informative git prompt for bash when it was first imported into the tree - you can still see the command in https://github.com/magicmonty/bash-git-prompt/blob/21063bcd924bd8efb65eb36b2fe12ffd6ed1b6a5/gitstatus_pre-1.7.10.sh#L53

It would be possible to update it to use git status --porcelain or similar. I quite like the current behaviour, but I'm certainly not attached to it.

@zanchey zanchey added this to the fish-future milestone Sep 2, 2019
@marcvangend
Copy link
Author

Thanks @zanchey. As far as I can see, that line of code dates back to October 2015, which makes it extra interesting to see (magicmonty/bash-git-prompt#27) that this behavior had already been reported as bug and fixed in 2013!

But anyway, IMHO the question we really should be answering is: Is this the behavior we want? Does it make sense? Personally, I think the behavior is confusing because AFAIK all of the other git status icons refer to the entire repo, not the current directory.

By the way, I don't think we would need to parse the output of git status --porcelain to change the behavior. As shown, __fish_git_prompt_untracked already returns the expected information, and does so by calling git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/.

@zanchey
Copy link
Member

zanchey commented Sep 3, 2019

Sure, I think we'd take a patch to fix it

@glass-ships

This comment has been minimized.

@faho

This comment has been minimized.

@glass-ships

This comment has been minimized.

@faho faho closed this as completed in ba116f1 May 28, 2020
@krobelus krobelus modified the milestones: fish-future, fish 3.2.0 May 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants