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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 27, 2013 at 15:10 UTC
c29e317994d1077fe3ac9cdeae5a5b35ffaa3440
1 file changed
+8
-20
contrib/completion/git-completion.bash
+8
-20
@@ -259,23 +259,6 @@ __gitcomp_file ()
259
compgen -f /non-existing-dir/ > /dev/null
260
}
261
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
-
262
# Execute 'git ls-files', unless the --committable option is specified, in
263
# which case it runs 'git diff-index' to find out the files that can be
264
# committed. It return paths relative to the directory specified in the first
@@ -303,11 +286,16 @@ __git_ls_files_helper ()
286
# slash.
287
__git_index_files ()
288
{
306
- local dir="$(__gitdir)" root="${2-.}"
289
+ local dir="$(__gitdir)" root="${2-.}" file
290
291
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
299
fi
300
}
301