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

Re: [PATCH v2 1/4] completion: add 'git history' subcommands

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 7, 2026, 06:30 UTC
Message-ID
<anV7cHblfmGvbl-e@pks.im>
In-Reply-To
<20260806-history_autocompletion-v2-1-7e60f52a1c20@kernel.org>
On Thu, Aug 06, 2026 at 10:27:36PM +0200, Vincent Mailhol wrote:
Show 17 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index e875787710..7372e2919b 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2137,6 +2137,54 @@ _git_help ()
>  	fi
>  }
>  
> +__git_history_has_revision ()
> +{
> +	local i
> +
> +	for ((i = __git_cmd_idx + 2; i < cword; i++)); do
> +		case "${words[i]}" in
> +		--empty|--update-refs)
> +			((i++))
> +			;;

This will unfortunately be quite a pain to maintain going forward, as we now have to be aware of updating this site every single time we add a new option that accepts a parameter.

I don't really have a good idea for how to fix that reliably though, I have to admit. Maybe we should just mostly ignore this edge case and always complete references, unless we have seen a `--`? That can be checked rather easily via `__git_hash_doubledash`.

That'd still be a huge win compared to the status quo, and if we really care about making this work properly we can still iterate.

Patrick
Previous: Vincent MailholNext: Vincent Mailhol
Message 3 of 17 in “completion: add support for 'git history'”
  1. 0/4 completion: add support for 'git history'Vincent Mailhol, Aug 6, 2026
  2. 1/4 completion: add 'git history' subcommandsVincent Mailhol, Aug 6, 2026
  3. Patrick SteinhardtAug 7, 2026
  4. Vincent MailholAug 7, 2026
  5. Patrick SteinhardtAug 7, 2026
  6. Vincent MailholAug 7, 2026
  7. D. Ben KnobleAug 10, 2026
  8. 2/4 completion: complete 'git history --empty' valuesVincent Mailhol, Aug 6, 2026
  9. D. Ben KnobleAug 10, 2026
  10. D. Ben KnobleAug 10, 2026
  11. Vincent MailholAug 13, 2026
  12. Ben KnobleAug 13, 2026
  13. Vincent MailholAug 13, 2026
  14. 3/4 completion: complete 'git history --update-refs' valuesVincent Mailhol, Aug 6, 2026
  15. D. Ben KnobleAug 10, 2026
  16. 4/4 completion: complete 'git history split' pathspecsVincent Mailhol, Aug 6, 2026
  17. D. Ben KnobleAug 10, 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.