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

Re: [PATCH v2 2/2] completion: add git status

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 1, 2016, 12:15 UTC
Message-ID
<20160601141510.Horde.M2zGuJrzBNqf_2zYLo0P2Sx@webmail.informatik.kit.edu>
In-Reply-To
<1464773857.4315.1.camel@virtuell-zuhause.de>
Quoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:
Show 41 quoted lines
> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
> ---
>  contrib/completion/git-completion.bash | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash  
> b/contrib/completion/git-completion.bash
> index addea89..77343da 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1782,6 +1782,35 @@ _git_stage ()
>  	_git_add
>  }
>
> +_git_status ()
> +{
> +	case "$cur" in
> +	--ignore-submodules=*)
> +		__gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
> +		return
> +		;;
> +	--untracked-files=*)
> +		__gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
> +		return
> +		;;
> +	--column=*)
> +		__gitcomp "
> +			always never auto column row plain dense nodense
> +			" "" "${cur##--column=}"
> +		return
> +		;;
> +	--*)
> +		__gitcomp "
> +			--short --branch --porcelain --long --verbose
> +			--untracked-files= --ignore-submodules= --ignored
> +			--column= --no-column
> +			"
> +		return
> +		;;
> +	esac
> +	__git_complete_file

__git_complete_file()'s job is to complete the '<rev>:<path>' notation, e.g. 'master:Mak<TAB>', which is not what we want here, because this notation doesn't make sense for 'git status' and because 'git status <TAB>' would then offer refs instead of files.

I think there are two choices what to do instead:
   - Don't do anything :)  Bash will then fall back to filename
     completion, which is quite close to what we want here (and in this
     case the return statements from the other case arms can go away as
     well).  The drawback is that all ignored files in the current
     working directory will show up after 'git status <TAB>'.
   - use __git_complete_index_file() with appropriate options, perhaps
     '--cached --others', but I didn't think this through.  For bonus
     points pass additional options when certain 'git status' options are
     already present on the command line, e.g. pass '--ignored', too, if
     it is present.
Show 5 quoted lines
> +}
> +
>  __git_config_get_set_variables ()
>  {
>  	local prevword word config_file= c=$cword
Previous: Thomas BraunNext: Thomas Braun
Message 9 of 33 in “completion: create variable for untracked file modes”
  1. 1/2 completion: create variable for untracked file modesThomas Braun, May 31, 2016
  2. Jeff KingJun 1, 2016
  3. Junio C HamanoJun 1, 2016
  4. Thomas BraunJun 1, 2016
  5. 1/2 completion: create variable for untracked file modesThomas Braun, Jun 1, 2016
  6. SZEDER GáborJun 1, 2016
  7. Thomas BraunJun 2, 2016
  8. 2/2 completion: add git statusThomas Braun, Jun 1, 2016
  9. SZEDER GáborJun 1, 2016
  10. Thomas BraunJun 2, 2016
  11. 1/2 completion: factor out untracked file modes into a variableThomas Braun, Jun 2, 2016
  12. 2/2 completion: add git statusThomas Braun, Jun 2, 2016
  13. Junio C HamanoJun 2, 2016
  14. Thomas BraunJun 3, 2016
  15. Junio C HamanoJun 3, 2016
  16. Jeff KingJun 3, 2016
  17. Junio C HamanoJun 3, 2016
  18. Thomas BraunJun 3, 2016
  19. 0/3 support completion for git statusThomas Braun, Jun 3, 2016
  20. 1/3 completion: factor out untracked file modes into a variableThomas Braun, Jun 3, 2016
  21. 2/3 completion: add __git_get_option_value helperThomas Braun, Jun 3, 2016
  22. SZEDER GáborJun 10, 2016
  23. Thomas BraunJun 25, 2016
  24. 3/3 completion: add git statusThomas Braun, Jun 3, 2016
  25. Junio C HamanoJun 6, 2016
  26. Thomas BraunJun 7, 2016
  27. Junio C HamanoJun 6, 2016
  28. 0/3 completion: add git statusThomas Braun, Jun 10, 2016
  29. 2/3 completion: add __git_get_option_value helperThomas Braun, Jun 10, 2016
  30. 1/3 completion: factor out untracked file modes into a variableThomas Braun, Jun 10, 2016
  31. 3/3 completion: add git statusThomas Braun, Jun 10, 2016
  32. 1/3 completion: factor out untracked file modes into a variableThomas Braun, Jun 10, 2016
  33. 3/3 completion: add git statusThomas Braun, Jun 10, 2016

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.