summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGravatar memeplex <memeplex@web>2017-04-14 20:19:31 +0000
committerGravatar admin <admin@branchable.com>2017-04-14 20:19:31 +0000
commit5f450f7b514f7eaedd68b6d988b1b10baf78bfd9 (patch)
tree19a277d3efafa47fb2956139d1a3fd0c2f008999 /doc
parentf88d9965e374093e4969029544626df2f0629003 (diff)
Diffstat (limited to 'doc')
-rw-r--r--doc/tips/Faster_bash_autocompletion_with_big_annex_repos.mdwn50
1 files changed, 50 insertions, 0 deletions
diff --git a/doc/tips/Faster_bash_autocompletion_with_big_annex_repos.mdwn b/doc/tips/Faster_bash_autocompletion_with_big_annex_repos.mdwn
new file mode 100644
index 000000000..ded86df72
--- /dev/null
+++ b/doc/tips/Faster_bash_autocompletion_with_big_annex_repos.mdwn
@@ -0,0 +1,50 @@
+I'm currently using git annex to manage my entire file collection
+(including tons of music and books) and I noticed how slow
+autocompletion has become for files in the index (say for git add).
+The main offender is a while-read-case-echo bash loop in
+`__git_index_files` that can be readily substituted with a much faster
+sed invocation. Here is my benchmark:
+
+```
+__git_index_files ()
+{
+ local dir="$(__gitdir)" root="${2-.}" file;
+ if [ -d "$dir" ]; then
+ __git_ls_files_helper "$root" "$1" | while read -r file; do
+ case "$file" in
+ ?*/*)
+ echo "${file%%/*}"
+ ;;
+ *)
+ echo "$file"
+ ;;
+ esac;
+ done | sort | uniq;
+ fi
+}
+
+time __git_index_files > /dev/null
+
+
+__git_index_files ()
+{
+ local dir="$(__gitdir)" root="${2-.}" file;
+ if [ -d "$dir" ]; then
+ __git_ls_files_helper "$root" "$1" | \
+ sed -r 's@^"?([^/]+)/.*$@\1@' | sort | uniq
+ fi
+}
+
+time __git_index_files > /dev/null
+
+real 0m0.830s
+user 0m0.597s
+sys 0m0.310s
+
+real 0m0.345s
+user 0m0.357s
+sys 0m0.000s
+```
+
+So you might redefine `__git_index_files` as above in your .bashrc after sourcing the git autocomplete script.
+