638
}
639
640
641
-# __git_index_files accepts 1 to 4 arguments:
641
+# __git_index_files accepts 1 to 3 arguments:
642
# 1: Options to pass to ls-files (required).
643
# 2: A directory path (optional).
644
# If provided, only files within the specified directory are listed.
645
# Sub directories are never recursed. Path must have a trailing
646
# slash.
647
# 3: List only paths matching this path component (optional).
648
-# 4: Hide paths whose first component starts with a dot if this is
649
-# "hide-dotfiles" and the third argument is empty (optional).
648
+#
649
+# If the third argument is empty, paths that begin with a dot (dotfiles)
650
+# are hidden. This matches user expectations where dotfiles are considered
651
+# hidden configuration files/directories and shouldn't clutter default
652
+# completions unless explicitly requested by typing a dot.
653
__git_index_files ()
654
{
652
- local root="$2" match="$3" hide_dotfiles="${4-}"
655
+ local root="$2" match="$3"
656
local hide_dotfiles_awk=0
654
- if [ "$hide_dotfiles" = "hide-dotfiles" ] && [ -z "$match" ]; then
657
+ if [ -z "$match" ]; then
658
hide_dotfiles_awk=1
659
fi
660
664
}
665
END {
666
for (p in paths) {
664
- if (substr(p, 1, 1) != "\"") {
665
- # No special characters, easy!
666
- if (hide_dotfiles == 1 && substr(p, 1, 1) == ".")
667
+ if (substr(p, 1, 1) == "\"") {
668
+ # The path is quoted.
669
+ p = dequote(p)
670
+ if (p == "")
671
continue
668
- print pfx p
669
- continue
670
- }
671
-
672
- # The path is quoted.
673
- p = dequote(p)
674
- if (p == "")
675
- continue
672
677
- # Even when a directory name itself does not contain
678
- # any special characters, it will still be quoted if
679
- # any of its (stripped) trailing path components do.
680
- # Because of this we may have seen the same directory
681
- # both quoted and unquoted.
682
- if (p in paths)
683
- # We have seen the same directory unquoted,
684
- # skip it.
685
- continue
673
+ # Even when a directory name itself does not contain
674
+ # any special characters, it will still be quoted if
675
+ # any of its (stripped) trailing path components do.
676
+ # Because of this we may have seen the same directory
677
+ # both quoted and unquoted.
678
+ if (p in paths)
679
+ # We have seen the same directory unquoted,
680
+ # skip it.
681
+ continue
682
+ }
683
684
if (hide_dotfiles == 1 && substr(p, 1, 1) == ".")
685
continue
728
}'
729
}
730
734
-# __git_complete_index_file accepts 1 or 2 arguments:
735
-# 1: the options to pass to ls-file
736
-# 2: Hide paths whose first component starts with a dot if this is
737
-# "hide-dotfiles" and the current word is empty (optional).
731
+# __git_complete_index_file accepts 1 argument:
732
+# 1: the options to pass to ls-files
733
#
734
# The exception is --committable, which finds the files appropriate commit.
735
__git_complete_index_file ()
736
{
742
- local dequoted_word pfx="" cur_ hide_dotfiles="${2-}"
737
+ local dequoted_word pfx="" cur_
738
739
__git_dequote "$cur"
740
747
cur_="$dequoted_word"
748
esac
749
755
- __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_" "$hide_dotfiles")"
750
+ __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
751
}
752
753
# Lists branches from the local repository.
2171
2172
# XXX ignore options like --modified and always suggest all cached
2173
# files.
2179
- __git_complete_index_file "--cached" hide-dotfiles
2174
+ __git_complete_index_file "--cached"
2175
}
2176
2177
_git_ls_remote ()
2404
if [ $(__git_count_arguments "mv") -gt 0 ]; then
2405
# We need to show both cached and untracked files (including
2406
# empty directories) since this may not be the last argument.
2412
- __git_complete_index_file "--cached --others --directory" hide-dotfiles
2407
+ __git_complete_index_file "--cached --others --directory"
2408
else
2414
- __git_complete_index_file "--cached" hide-dotfiles
2409
+ __git_complete_index_file "--cached"
2410
fi
2411
}
2412
3226
;;
3227
esac
3228
3234
- __git_complete_index_file "--cached" hide-dotfiles
3229
+ __git_complete_index_file "--cached"
3230
}
3231
3232
_git_shortlog ()