git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bash completion very slow in large repo

From
Matthew Hughes <matthewhughes934@gmail.com>
Date
Aug 19, 2026, 20:25 UTC
Message-ID
<aoYQ9CCzPM3qKVfZ@desktop>
In-Reply-To
<an9iXOqOOvFfyN4A@desktop>
On Fri, Aug 14, 2026 at 07:55:36PM +0100, Matthew Hughes wrote:
> I'm not sure about potential fixes. Hacking around on it the best I could come
> up with was a workaround: add an env var to skip index completion during bash
> completion, so the completion falls back to the default Bash file completion
> (i.e. complete any time), here that is (just for demonstration):

My final workaround (read: filthy hack) was to re-define `__git_complete_index_file` just after sourcing the completion script like:

    # copy __git_complete_index_file to __orig__git_complete_index_file
    eval "__orig$(declare -f __git_complete_index_file)"
    __git_complete_index_file () {
        # options that require 'git' to inspect all files on disk
        local slow_opts_re="(^|[[:space:]])(--others|--modified|--deleted|--ignored|--killed)($|[[:space:]])"    
        if [[ "$1" =~ $slow_opts_re ]]
        then
            return
        fi
        __orig__git_complete_index_file "$@"
    }
Previous: Matthew Hughes
Message 4 of 4 in “Bash completion very slow in large repo”
  1. Matthew HughesAug 14, 2026
  2. D. Ben KnobleAug 15, 2026
  3. Matthew HughesAug 15, 2026
  4. Matthew HughesAug 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.