git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] worktree: add completion for the rev argument in git worktree add <path> <rev>
@ 2018-12-10 15:10 Johannes Schindelin via GitGitGadget
  2018-12-10 15:10 ` [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>` Johannes Schindelin via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-12-10 15:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

This is inspired by one of those half-finished contributions in the Git for
Windows project. Fall cleaning, if you like.

Johannes Schindelin (1):
  completion: complete <rev> in `git worktree add <path> <rev>`

 contrib/completion/git-completion.bash | 5 +++++
 1 file changed, 5 insertions(+)


base-commit: d166e6afe5f257217836ef24a73764eba390c58d
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-82%2Fdscho%2Fcomplete-worktree-add-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-82/dscho/complete-worktree-add-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/82
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`
  2018-12-10 15:10 [PATCH 0/1] worktree: add completion for the rev argument in git worktree add <path> <rev> Johannes Schindelin via GitGitGadget
@ 2018-12-10 15:10 ` Johannes Schindelin via GitGitGadget
  2018-12-11  2:34   ` SZEDER Gábor
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-12-10 15:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The second non-option argument to `git worktree`'s `add` command is an
optional revision. Let's complete it.

Inspired by https://github.com/git-for-windows/git/pull/1681.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/completion/git-completion.bash | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9e8ec95c3c..4194b4a2e7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2773,6 +2773,11 @@ _git_worktree ()
 		add,--*)
 			__gitcomp_builtin worktree_add
 			;;
+		add,*)
+			if [ $(__git_count_arguments "worktree") -eq 2 ]; then
+				__git_complete_refs
+			fi
+			;;
 		list,--*)
 			__gitcomp_builtin worktree_list
 			;;
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`
  2018-12-10 15:10 ` [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>` Johannes Schindelin via GitGitGadget
@ 2018-12-11  2:34   ` SZEDER Gábor
  0 siblings, 0 replies; 3+ messages in thread
From: SZEDER Gábor @ 2018-12-11  2:34 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Junio C Hamano, Johannes Schindelin

On Mon, Dec 10, 2018 at 07:10:46AM -0800, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> The second non-option argument to `git worktree`'s `add` command is an
> optional revision. Let's complete it.
> 
> Inspired by https://github.com/git-for-windows/git/pull/1681.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  contrib/completion/git-completion.bash | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 9e8ec95c3c..4194b4a2e7 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2773,6 +2773,11 @@ _git_worktree ()
>  		add,--*)
>  			__gitcomp_builtin worktree_add
>  			;;
> +		add,*)
> +			if [ $(__git_count_arguments "worktree") -eq 2 ]; then
> +				__git_complete_refs
> +			fi
> +			;;

Unfortunately, this seems to work only in the following case:

  git worktree add path <TAB>

i.e. when the two-be-completed word is still empty.  However,

  git worktree add path m<TAB>

doesn't work anymore, as it lists paths instead of refs.  Furthermore,

  git worktree add --detach path <TAB>
  git worktree add --detach path m<TAB>
  git worktree add -b newbranch path <TAB>

list paths as well.

However, I presume unintentionally,

  git worktree add -b <TAB>

does the right thing and lists refs, but with

  git worktree add -b m<TAB>

we are back at paths instead of refs.  OTOH,

  git worktree add --detach <TAB>
  git worktree add --lock <TAB>

will erroneously list refs.

I wrote a completion function for 'git worktree' a long while ago,
back when it had only two subcommands, which did mostly the right
thing, but I found it too convoluted for serious submission.  Here it
is for inspiration:

  https://public-inbox.org/git/1440190256-21794-1-git-send-email-szeder@ira.uka.de/

>  		list,--*)
>  			__gitcomp_builtin worktree_list
>  			;;
> -- 
> gitgitgadget

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-11  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 15:10 [PATCH 0/1] worktree: add completion for the rev argument in git worktree add <path> <rev> Johannes Schindelin via GitGitGadget
2018-12-10 15:10 ` [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>` Johannes Schindelin via GitGitGadget
2018-12-11  2:34   ` SZEDER Gábor

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).