Skip to content

[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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

soraxas
Copy link
Contributor

@soraxas soraxas commented Aug 6, 2025

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. What yadm 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
Screenshot 2025-08-06 104720

By default it setup the git config variable to NOT show untracked files. This in-turns creates issues when completing add:
Screenshot 2025-08-06 104805
(notice the > 300K files)

Now, you can see that the git config is setup correctly:
Screenshot 2025-08-06 105002

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

(BTW, noticing how the current behaviour is actually the all behaviour of including files within untracked folders)


The behaviour after this PR:

Screenshot 2025-08-06 105848

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:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

soraxas added 2 commits August 6, 2025 01:06
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
@soraxas soraxas changed the title Respect Git canonical config for untracked files [completion] Respect Git canonical config for untracked files Aug 6, 2025
@@ -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``.
Copy link
Contributor

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)'
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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

@krobelus krobelus added this to the fish 4.1 milestone Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants