-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[completion] Respect Git canonical config for untracked files #11709
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
@@ -33,11 +33,11 @@ Boolean options (those which enable or disable something) understand "1", "yes" | |||
- ``$__fish_git_prompt_show_informative_status`` or the git option ``bash.showInformativeStatus`` can be set to 1, true or yes to enable the "informative" display, which will show a large amount of information - the number of dirty files, unpushed/unpulled commits, and more. | |||
In large repositories, this can take a lot of time, so you may wish to disable it in these repositories with ``git config --local bash.showInformativeStatus false``. It also changes the characters the prompt uses to less plain ones (``✚`` instead of ``*`` for the dirty state for example) , and if you are only interested in that, set ``$__fish_git_prompt_use_informative_chars`` instead. | |||
|
|||
Because counting untracked files requires a lot of time, the number of untracked files is only shown if enabled via ``$__fish_git_prompt_showuntrackedfiles`` or the git option ``bash.showUntrackedFiles``. | |||
Because counting untracked files requires a lot of time, the number of untracked files is only shown if enabled via ``$__fish_git_prompt_showuntrackedfiles`` or the git option ``status.showUntrackedFiles``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have much reason to change the git prompt; the upstream version from Git also only supports bash.showUntrackedFiles
.
(also because one may want to configure the prompt independent of git status
behavior)
I guess we could fall back to status.showUntrackedFiles here, if bash.showUntrackedFiles is not defined.. but I'd rather change it upstream first, if at all.
If upstream changes this, then we should definitely follow.
# If we have so many files that you disable untrackedfiles, let's add file completions, | ||
# to avoid slurping megabytes of git output. | ||
complete -F -c git -n '__fish_git_using_command add; and test "$(__fish_git config --get bash.showUntrackedFiles)" = 0' -a '(__fish_git_files modified deleted unmerged modified-staged-deleted)' | ||
complete -F -c git -n '__fish_git_using_command add; and test "$(__fish_git config --type bool --get status.showUntrackedFiles)" = false' -a '(__fish_git_files modified deleted unmerged modified-staged-deleted)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to not break existing behavior, we should probably allow both, e.g. and begin test bash.showUntrackedFiles ... || test status.showUntrackedFiles ...; end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I agree with the review on the git prompt.
However, using the same argument, wouldn't it not make sense to piggyback on the bash.xxxx option (which is intented for git prompt)? Doing so has the same effect of coupling the two config behaviour
As seen here, the bash.xxx
option is only intented for the git prompt (https://github.com/search?q=repo%3Agit%2Fgit%20bash.showUntrackedFiles&type=code) , whereas the status.xxx
one actually changes the core git behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git blame shows the original motivation for setting bash.showUntrackedFiles
was #11095 which also stated
Also git option status.showUntrackedFiles is set to no, to make it usable
so it looks like they already set the standard option.
Given that there is probably barely anyone relying on only the bash.showUntrackedFiles, I'm fine with this change, yeah
Description
The git completion was not respecting git config for ignoring untracked files.
I am using something called
yadm
to track my dotfiles in a bare git repository. Whatyadm
is doesn't really matter, as it just setup GIT environment variable and configs under hood. I'll demonstrates the same principle with raw git:This shows that it's showing my dotfiles status

By default it setup the git config variable to NOT show untracked files. This in-turns creates issues when completing

add
:(notice the > 300K files)
Now, you can see that the git config is setup correctly:

where its using the option here: https://git-scm.com/docs/git-config

(BTW, noticing how the current behaviour is actually the
all
behaviour of including files within untracked folders)The behaviour after this PR:
Discussion
Regarding the previous
bash.showUntrackedFiles
option: I was able to find traces of it in the git source repo, and apparently I think it used to be a contrib module for completion:https://github.com/search?q=repo%3Agit%2Fgit%20bash.showUntrackedFiles&type=code
But i reckon we should now use the canonical git config option?
https://github.com/search?q=repo%3Agit%2Fgit+status.showUntrackedFiles&type=code
TODOs: