{"thread":{"id":"49992","subject":"[PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`","startedAt":"2018-12-10T15:10:51Z","lastAt":"2018-12-11T02:34:56Z","messageCount":3,"participants":["Johannes Schindelin via GitGitGadget","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"364924","messageId":"830191fbfbf95b9d568ba91ddcdd9860173a476a.1544454643.git.gitgitgadget@gmail.com","threadId":"49992","inReplyTo":"pull.82.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-12-10T15:10:46Z","receivedAt":"2018-12-10T15:10:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe second non-option argument to `git worktree`'s `add` command is an\noptional revision. Let's complete it.\n\nInspired by https://github.com/git-for-windows/git/pull/1681.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/completion/git-completion.bash | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9e8ec95c3c..4194b4a2e7 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2773,6 +2773,11 @@ _git_worktree ()\n \t\tadd,--*)\n \t\t\t__gitcomp_builtin worktree_add\n \t\t\t;;\n+\t\tadd,*)\n+\t\t\tif [ $(__git_count_arguments \"worktree\") -eq 2 ]; then\n+\t\t\t\t__git_complete_refs\n+\t\t\tfi\n+\t\t\t;;\n \t\tlist,--*)\n \t\t\t__gitcomp_builtin worktree_list\n \t\t\t;;\n-- \ngitgitgadget\n"},{"id":"364925","messageId":"pull.82.git.gitgitgadget@gmail.com","threadId":"49992","inReplyTo":null,"subject":"[PATCH 0/1] worktree: add completion for the rev argument in git worktree add <path> <rev>","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-12-10T15:10:45Z","receivedAt":"2018-12-10T15:10:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This is inspired by one of those half-finished contributions in the Git for\nWindows project. Fall cleaning, if you like.\n\nJohannes Schindelin (1):\n  completion: complete <rev> in `git worktree add <path> <rev>`\n\n contrib/completion/git-completion.bash | 5 +++++\n 1 file changed, 5 insertions(+)\n\n\nbase-commit: d166e6afe5f257217836ef24a73764eba390c58d\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-82%2Fdscho%2Fcomplete-worktree-add-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-82/dscho/complete-worktree-add-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/82\n-- \ngitgitgadget\n"},{"id":"365016","messageId":"20181211023449.GS30222@szeder.dev","threadId":"49992","inReplyTo":"830191fbfbf95b9d568ba91ddcdd9860173a476a.1544454643.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-12-11T02:34:49Z","receivedAt":"2018-12-11T02:34:56Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Dec 10, 2018 at 07:10:46AM -0800, Johannes Schindelin via GitGitGadget wrote:\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> The second non-option argument to `git worktree`'s `add` command is an\n> optional revision. Let's complete it.\n> \n> Inspired by https://github.com/git-for-windows/git/pull/1681.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  contrib/completion/git-completion.bash | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 9e8ec95c3c..4194b4a2e7 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2773,6 +2773,11 @@ _git_worktree ()\n>  \t\tadd,--*)\n>  \t\t\t__gitcomp_builtin worktree_add\n>  \t\t\t;;\n> +\t\tadd,*)\n> +\t\t\tif [ $(__git_count_arguments \"worktree\") -eq 2 ]; then\n> +\t\t\t\t__git_complete_refs\n> +\t\t\tfi\n> +\t\t\t;;\n\nUnfortunately, this seems to work only in the following case:\n\n  git worktree add path <TAB>\n\ni.e. when the two-be-completed word is still empty.  However,\n\n  git worktree add path m<TAB>\n\ndoesn't work anymore, as it lists paths instead of refs.  Furthermore,\n\n  git worktree add --detach path <TAB>\n  git worktree add --detach path m<TAB>\n  git worktree add -b newbranch path <TAB>\n\nlist paths as well.\n\nHowever, I presume unintentionally,\n\n  git worktree add -b <TAB>\n\ndoes the right thing and lists refs, but with\n\n  git worktree add -b m<TAB>\n\nwe are back at paths instead of refs.  OTOH,\n\n  git worktree add --detach <TAB>\n  git worktree add --lock <TAB>\n\nwill erroneously list refs.\n\nI wrote a completion function for 'git worktree' a long while ago,\nback when it had only two subcommands, which did mostly the right\nthing, but I found it too convoluted for serious submission.  Here it\nis for inspiration:\n\n  https://public-inbox.org/git/1440190256-21794-1-git-send-email-szeder@ira.uka.de/\n\n>  \t\tlist,--*)\n>  \t\t\t__gitcomp_builtin worktree_list\n>  \t\t\t;;\n> -- \n> gitgitgadget\n"}]}