Skip to content

Commit c29e317

Browse files
felipecgitster
authored andcommitted
completion: remove __git_index_file_list_filter()
Refactor the code into the only caller; __git_index_files(). Also, Somehow messing up with the 'path' variable messes up the 'PATH' variable. So let's not do that. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbe4511 commit c29e317

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

contrib/completion/git-completion.bash

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,6 @@ __gitcomp_file ()
259259
compgen -f /non-existing-dir/ > /dev/null
260260
}
261261

262-
# Process path list returned by "ls-files" and "diff-index --name-only"
263-
# commands, in order to list only file names relative to a specified
264-
# directory, and append a slash to directory names.
265-
__git_index_file_list_filter ()
266-
{
267-
local path
268-
269-
while read -r path; do
270-
case "$path" in
271-
?*/*)
272-
echo "${path%%/*}" ;;
273-
*)
274-
echo "$path" ;;
275-
esac
276-
done
277-
}
278-
279262
# Execute 'git ls-files', unless the --committable option is specified, in
280263
# which case it runs 'git diff-index' to find out the files that can be
281264
# committed. It return paths relative to the directory specified in the first
@@ -303,11 +286,16 @@ __git_ls_files_helper ()
303286
# slash.
304287
__git_index_files ()
305288
{
306-
local dir="$(__gitdir)" root="${2-.}"
289+
local dir="$(__gitdir)" root="${2-.}" file
307290

308291
if [ -d "$dir" ]; then
309-
__git_ls_files_helper "$root" "$1" | __git_index_file_list_filter |
310-
sort | uniq
292+
__git_ls_files_helper "$root" "$1" |
293+
while read -r file; do
294+
case "$file" in
295+
?*/*) echo "${file%%/*}" ;;
296+
*) echo "$file" ;;
297+
esac
298+
done | sort | uniq
311299
fi
312300
}
313301

0 commit comments

Comments
 (0)