]> git.ipfire.org Git - thirdparty/git.git/commit
completion: hide dotfiles by default for path completion
authorZakariyah Ali <zakariyahali100@gmail.com>
Sat, 20 Jun 2026 17:55:56 +0000 (17:55 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 21 Jun 2026 01:02:48 +0000 (18:02 -0700)
commit2cc01b9c55de08d03f30e7ec43236aa08a829dc0
tree5d5c09904cf1399ebf75335d56da90a3fbc53a99
parent7f5550445099f501dd16299c49f59a0dd949d237
completion: hide dotfiles by default for path completion

The previous implementation required callers to explicitly pass a
"hide-dotfiles" flag to __git_complete_index_file to avoid cluttering
completions with hidden files. This led to inconsistent behavior across
commands (e.g., `git add` and `git mv` behaved differently) and forced
callers to maintain repetitive logic.

As suggested by Junio C Hamano, this commit simplifies the logic:
1. __git_complete_index_file now unconditionally hides dotfiles when
   no match pattern is provided.
2. The awk loop in __git_index_files is refactored to check the dotfile
   condition in a single, obvious place after handling path dequoting,
   removing the previous duplication.
3. Callers no longer need to pass "hide-dotfiles".

This provides a cleaner API and ensures a consistent, expected behavior
where dotfiles are hidden unless explicitly requested by typing a dot.

Signed-off-by: Zakariyah Ali <zakariyahali100@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash
t/t9902-completion.sh