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, 07:08 UTC
Message-ID
<anWEcfhdzvNQfskU@pks.im>
In-Reply-To
<e894cf4e-7df2-489a-a596-96f1d4d95dc0@kernel.org>
On Fri, Aug 07, 2026 at 08:44:41AM +0200, Vincent Mailhol wrote:
Show 25 quoted lines
> On 07/08/2026 at 08:30, Patrick Steinhardt wrote:
> > On Thu, Aug 06, 2026 at 10:27:36PM +0200, Vincent Mailhol wrote:
> >> 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.
> 
> Do you foreseen such new parameters?

Yes, I'm very sure we'll gain more parameters for those commands. Commit signing, sign-offs, handling of notes are all things that are currently being discussed, and they likely will require new options.

Show 35 quoted lines
> > 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`.
> 
> My toughs are that if such a special case ever surface, we can just
> dispatch it earlier before we check for the
> __git_history_has_revision, like this:
> 
> ---8<---
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index d313780d8b..786fcb5e16 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2193,6 +2193,15 @@ _git_history ()
>  		esac
>  	fi
>  
> +	# Subcommands which takes something else than a revision
> +	case "$subcommand" in
> +	foo)
> +		# 'git history foo' take a file first
> +		__git_complete_index_file "--cached"
> +		return
> +		;;
> +	esac
> +
>  	if ! __git_history_has_revision; then
>  		__git_complete_refs
>  		return
> ---8<---
> 
> This seems reasonable to me. Once we know what this mysterious new
> command would be, maybe we can find a smarter and more tailored
> solution, but at the moment, I would not call this a blocker.

I'm not really concerned about new subcommands for now, true. But hardcoding the parameters as we do above feels error prone to me and will very likely diverge as the command evolves.

Patrick
Previous: Vincent MailholNext: Vincent Mailhol
Message 5 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.