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

Re: [PATCH] completion: Support the DWIM mode for git checkout

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Oct 10, 2010, 21:16 UTC
Message-ID
<20101010211634.GA4730@neumann>
In-Reply-To
<1286496492-65221-1-git-send-email-kevin@sb.org>
Hi,
On Thu, Oct 07, 2010 at 05:08:12PM -0700, Kevin Ballard wrote:
> Signed-off-by: Kevin Ballard <kevin@sb.org>
> ---

I think the commit message should add some details about how the patch changes the completion script's behavior. At least I didn't know offhand what "DWIM mode for git checkout" is, and once I found it (70c9ac2 (DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz", 2009-10-18), right?), I didn't know how the completion script is supposed to support that, and once I applied the patch and played around a bit, I was surprised that only 'git checkout h<tab>' includes the 'html' branch but 'git checkout <tab>' don't.

Show 7 quoted lines
>  contrib/completion/git-completion.bash |   35 +++++++++++++++++++++++++++++--
>  1 files changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index f83f019..be0498c 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
Show 16 quoted lines
> @@ -988,7 +1007,17 @@ _git_checkout ()
>  			"
>  		;;
>  	*)
> -		__gitcomp "$(__git_refs)"
> +		# check if --track, --no-track, or --no-guess was specified
> +		# if so, disable DWIM mode
> +		local i c=1 track=1
> +		while [ $c -lt $COMP_CWORD ]; do
> +			i="${COMP_WORDS[c]}"
> +			case "$i" in
> +			--track|--no-track|--no-guess) track=''; break ;;
> +			esac
> +			c=$((++c))
> +		done
> +		__gitcomp "$(__git_refs '' $track)"
You could use the __git_find_on_cmdline() helper function instead.

Best, Gábor

Previous: Kevin BallardNext: Kevin Ballard
Message 2 of 4 in “completion: Support the DWIM mode for git checkout”
  1. completion: Support the DWIM mode for git checkoutKevin Ballard, Oct 8, 2010
  2. SZEDER GáborOct 10, 2010
  3. Kevin BallardOct 10, 2010
  4. completion: Support the DWIM mode for git checkoutKevin Ballard, Oct 12, 2010

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.