* [PATCH] completion: optionally disable checkout DWIM @ 2017-04-20 20:12 Jeff King 2017-04-21 5:01 ` Junio C Hamano ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Jeff King @ 2017-04-20 20:12 UTC (permalink / raw) To: git When we complete branch names for "git checkout", we also complete remote branch names that could trigger the DWIM behavior. Depending on your workflow and project, this can be either convenient or annoying. For instance, my clone of gitster.git contains 74 local "jk/*" branches, but origin contains another 147. When I want to checkout a local branch but can't quite remember the name, tab completion shows me 251 entries. And worse, for a topic that has been picked up for pu, the upstream branch name is likely to be similar to mine, leading to a high probability that I pick the wrong one and accidentally create a new branch. This patch adds a way for the user to tell the completion code not to include DWIM suggestions for checkout. This can already be done by typing: git checkout --no-guess jk/<TAB> but that's rather cumbersome. The downside, of course, is that you no longer get completion support when you _do_ want to invoke the DWIM behavior. But depending on your workflow, that may not be a big loss (for instance, in git.git I am much more likely to want to detach, so I'd type "git checkout origin/jk/<TAB>" anyway). Signed-off-by: Jeff King <peff@peff.net> --- This is flexible enough for me, but it's possible somebody would want this on a per-repo basis. I don't know that we want to read from `git config`, though, because it's relatively expensive to do so. People who want per-repo settings are probably better off with a hook that triggers when they "cd" around, and sets up their preferences. contrib/completion/git-completion.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1150164d5..f53b18fae 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -28,6 +28,14 @@ # completion style. For example '!f() { : git commit ; ... }; f' will # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". +# +# You can set the following environment variables to influence the behavior of +# the completion routines: +# +# GIT_COMPLETION_CHECKOUT_NO_GUESS +# +# When non-empty, do not include "DWIM" suggestions in git-checkout +# completion (e.g., completing "foo" when "origin/foo" exists). case "$COMP_WORDBREAKS" in *:*) : great ;; @@ -1248,7 +1256,8 @@ _git_checkout () # check if --track, --no-track, or --no-guess was specified # if so, disable DWIM mode local flags="--track --no-track --no-guess" track_opt="--track" - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ + -n "$(__git_find_on_cmdline "$flags")" ]; then track_opt='' fi __git_complete_refs $track_opt -- 2.13.0.rc0.363.g8726c260e ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-20 20:12 [PATCH] completion: optionally disable checkout DWIM Jeff King @ 2017-04-21 5:01 ` Junio C Hamano 2017-04-21 5:03 ` Jeff King 2017-04-21 20:14 ` SZEDER Gábor 2017-04-21 7:25 ` Jacob Keller 2017-04-21 20:27 ` [PATCH v2] " Jeff King 2 siblings, 2 replies; 10+ messages in thread From: Junio C Hamano @ 2017-04-21 5:01 UTC (permalink / raw) To: Jeff King; +Cc: git, SZEDER Gábor Jeff King <peff@peff.net> writes: > When we complete branch names for "git checkout", we also > complete remote branch names that could trigger the DWIM > behavior. Depending on your workflow and project, this can > be either convenient or annoying. > ... > This is flexible enough for me, but it's possible somebody would want > this on a per-repo basis. I don't know that we want to read from `git > config`, though, because it's relatively expensive to do so. People who > want per-repo settings are probably better off with a hook that triggers > when they "cd" around, and sets up their preferences. Sounds OK. I am kind of surprised that --no-guess is the only way to turn off this dwimming (not in the completion side, but there does not seem to be a way to tell "git checkout" that you do not need that create-missing-branch-out-of-remote-tracking). > contrib/completion/git-completion.bash | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index 1150164d5..f53b18fae 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -28,6 +28,14 @@ > # completion style. For example '!f() { : git commit ; ... }; f' will > # tell the completion to use commit completion. This also works with aliases > # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". > +# > +# You can set the following environment variables to influence the behavior of > +# the completion routines: > +# > +# GIT_COMPLETION_CHECKOUT_NO_GUESS > +# > +# When non-empty, do not include "DWIM" suggestions in git-checkout > +# completion (e.g., completing "foo" when "origin/foo" exists). > > case "$COMP_WORDBREAKS" in > *:*) : great ;; > @@ -1248,7 +1256,8 @@ _git_checkout () > # check if --track, --no-track, or --no-guess was specified > # if so, disable DWIM mode > local flags="--track --no-track --no-guess" track_opt="--track" > - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then > + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ > + -n "$(__git_find_on_cmdline "$flags")" ]; then > track_opt='' > fi > __git_complete_refs $track_opt ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-21 5:01 ` Junio C Hamano @ 2017-04-21 5:03 ` Jeff King 2017-04-21 5:30 ` Junio C Hamano 2017-04-21 20:14 ` SZEDER Gábor 1 sibling, 1 reply; 10+ messages in thread From: Jeff King @ 2017-04-21 5:03 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, SZEDER Gábor On Thu, Apr 20, 2017 at 10:01:32PM -0700, Junio C Hamano wrote: > Jeff King <peff@peff.net> writes: > > > When we complete branch names for "git checkout", we also > > complete remote branch names that could trigger the DWIM > > behavior. Depending on your workflow and project, this can > > be either convenient or annoying. > > ... > > This is flexible enough for me, but it's possible somebody would want > > this on a per-repo basis. I don't know that we want to read from `git > > config`, though, because it's relatively expensive to do so. People who > > want per-repo settings are probably better off with a hook that triggers > > when they "cd" around, and sets up their preferences. > > Sounds OK. I am kind of surprised that --no-guess is the only way > to turn off this dwimming (not in the completion side, but there > does not seem to be a way to tell "git checkout" that you do not > need that create-missing-branch-out-of-remote-tracking). Yeah, I didn't even know about --no-guess until reading the completion script (it's intentionally undocumented). I did consider teaching checkout a config option for "do not DWIM". But I think it's really the completion that bugs me. The DWIM is easy to avoid triggering if you just don't feed it the remote branch names. It's the completion that routinely leads me to doing that. :) -Peff ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-21 5:03 ` Jeff King @ 2017-04-21 5:30 ` Junio C Hamano 0 siblings, 0 replies; 10+ messages in thread From: Junio C Hamano @ 2017-04-21 5:30 UTC (permalink / raw) To: Jeff King; +Cc: git, SZEDER Gábor Jeff King <peff@peff.net> writes: > ... But I think it's really the > completion that bugs me. The DWIM is easy to avoid triggering if you > just don't feed it the remote branch names. It's the completion that > routinely leads me to doing that. :) True. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-21 5:01 ` Junio C Hamano 2017-04-21 5:03 ` Jeff King @ 2017-04-21 20:14 ` SZEDER Gábor 2017-04-21 20:19 ` Jeff King 1 sibling, 1 reply; 10+ messages in thread From: SZEDER Gábor @ 2017-04-21 20:14 UTC (permalink / raw) To: Junio C Hamano; +Cc: Jeff King, Git mailing list On Fri, Apr 21, 2017 at 7:01 AM, Junio C Hamano <gitster@pobox.com> wrote: > Jeff King <peff@peff.net> writes: > >> When we complete branch names for "git checkout", we also >> complete remote branch names that could trigger the DWIM >> behavior. Depending on your workflow and project, this can >> be either convenient or annoying. >> ... >> This is flexible enough for me, but it's possible somebody would want >> this on a per-repo basis. I don't know that we want to read from `git >> config`, though, because it's relatively expensive to do so. People who >> want per-repo settings are probably better off with a hook that triggers >> when they "cd" around, and sets up their preferences. We could discern between more than just empty vs. non-empty state of the environment variable, e.g.: - if empty/unset, then include "DWIM" suggestions. - if set to 'config', then query the 'completion.checkoutNoGuess' configuration variable, and omit "DWIM" suggestions if its true. - if set to something else, then omit "DWIM" suggestions. Then users can themselves decide, whether the per-repo configurability is worth the overhead of running 'git config'. > Sounds OK. I am kind of surprised that --no-guess is the only way > to turn off this dwimming (not in the completion side, but there > does not seem to be a way to tell "git checkout" that you do not > need that create-missing-branch-out-of-remote-tracking). > >> contrib/completion/git-completion.bash | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash >> index 1150164d5..f53b18fae 100644 >> --- a/contrib/completion/git-completion.bash >> +++ b/contrib/completion/git-completion.bash >> @@ -28,6 +28,14 @@ >> # completion style. For example '!f() { : git commit ; ... }; f' will >> # tell the completion to use commit completion. This also works with aliases >> # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". >> +# >> +# You can set the following environment variables to influence the behavior of >> +# the completion routines: >> +# >> +# GIT_COMPLETION_CHECKOUT_NO_GUESS That's one long variable name :) Of course it has to start with the 'GIT_COMPLETION_' prefix, and you can't win from there... >> +# When non-empty, do not include "DWIM" suggestions in git-checkout >> +# completion (e.g., completing "foo" when "origin/foo" exists). >> >> case "$COMP_WORDBREAKS" in >> *:*) : great ;; >> @@ -1248,7 +1256,8 @@ _git_checkout () >> # check if --track, --no-track, or --no-guess was specified >> # if so, disable DWIM mode >> local flags="--track --no-track --no-guess" track_opt="--track" >> - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then >> + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ >> + -n "$(__git_find_on_cmdline "$flags")" ]; then || would be better than '-o', because the former short-circuits when the first condition is true, but the latter doesn't. >> track_opt='' >> fi >> __git_complete_refs $track_opt On Fri, Apr 21, 2017 at 7:01 AM, Junio C Hamano <gitster@pobox.com> wrote: > Jeff King <peff@peff.net> writes: > >> When we complete branch names for "git checkout", we also >> complete remote branch names that could trigger the DWIM >> behavior. Depending on your workflow and project, this can >> be either convenient or annoying. >> ... >> This is flexible enough for me, but it's possible somebody would want >> this on a per-repo basis. I don't know that we want to read from `git >> config`, though, because it's relatively expensive to do so. People who >> want per-repo settings are probably better off with a hook that triggers >> when they "cd" around, and sets up their preferences. > > Sounds OK. I am kind of surprised that --no-guess is the only way > to turn off this dwimming (not in the completion side, but there > does not seem to be a way to tell "git checkout" that you do not > need that create-missing-branch-out-of-remote-tracking). > >> contrib/completion/git-completion.bash | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash >> index 1150164d5..f53b18fae 100644 >> --- a/contrib/completion/git-completion.bash >> +++ b/contrib/completion/git-completion.bash >> @@ -28,6 +28,14 @@ >> # completion style. For example '!f() { : git commit ; ... }; f' will >> # tell the completion to use commit completion. This also works with aliases >> # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". >> +# >> +# You can set the following environment variables to influence the behavior of >> +# the completion routines: >> +# >> +# GIT_COMPLETION_CHECKOUT_NO_GUESS >> +# >> +# When non-empty, do not include "DWIM" suggestions in git-checkout >> +# completion (e.g., completing "foo" when "origin/foo" exists). >> >> case "$COMP_WORDBREAKS" in >> *:*) : great ;; >> @@ -1248,7 +1256,8 @@ _git_checkout () >> # check if --track, --no-track, or --no-guess was specified >> # if so, disable DWIM mode >> local flags="--track --no-track --no-guess" track_opt="--track" >> - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then >> + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ >> + -n "$(__git_find_on_cmdline "$flags")" ]; then >> track_opt='' >> fi >> __git_complete_refs $track_opt ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-21 20:14 ` SZEDER Gábor @ 2017-04-21 20:19 ` Jeff King 2017-04-22 17:32 ` SZEDER Gábor 0 siblings, 1 reply; 10+ messages in thread From: Jeff King @ 2017-04-21 20:19 UTC (permalink / raw) To: SZEDER Gábor; +Cc: Junio C Hamano, Git mailing list On Fri, Apr 21, 2017 at 10:14:48PM +0200, SZEDER Gábor wrote: > >> This is flexible enough for me, but it's possible somebody would want > >> this on a per-repo basis. I don't know that we want to read from `git > >> config`, though, because it's relatively expensive to do so. People who > >> want per-repo settings are probably better off with a hook that triggers > >> when they "cd" around, and sets up their preferences. > > We could discern between more than just empty vs. non-empty state of > the environment variable, e.g.: > > - if empty/unset, then include "DWIM" suggestions. > - if set to 'config', then query the 'completion.checkoutNoGuess' > configuration variable, and omit "DWIM" suggestions if its true. > - if set to something else, then omit "DWIM" suggestions. > > Then users can themselves decide, whether the per-repo configurability > is worth the overhead of running 'git config'. Yep, that would work. I wasn't going to bother with that complexity unless somebody really wanted it. The important thing is not to paint ourselves into a corner. By the rules you gave above, it would probably be fine to extend my patch later to match. But we could also be more specific (e.g., look for some positive value like "1"). > >> +# You can set the following environment variables to influence the behavior of > >> +# the completion routines: > >> +# > >> +# GIT_COMPLETION_CHECKOUT_NO_GUESS > > That's one long variable name :) > Of course it has to start with the 'GIT_COMPLETION_' prefix, and you > can't win from there... Yeah, I had the same thought. I also considered using "DWIM", which is the name by which I know the feature. But since "--no-guess" is the matching option, I went with that. > >> @@ -1248,7 +1256,8 @@ _git_checkout () > >> # check if --track, --no-track, or --no-guess was specified > >> # if so, disable DWIM mode > >> local flags="--track --no-track --no-guess" track_opt="--track" > >> - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then > >> + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ > >> + -n "$(__git_find_on_cmdline "$flags")" ]; then > > || would be better than '-o', because the former short-circuits when > the first condition is true, but the latter doesn't. Ah, I didn't know that. Usually I use "||", but I thought "-o" was generally preferred in bash-specific scripts. We definitely want to short circuit here. -Peff ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-21 20:19 ` Jeff King @ 2017-04-22 17:32 ` SZEDER Gábor 0 siblings, 0 replies; 10+ messages in thread From: SZEDER Gábor @ 2017-04-22 17:32 UTC (permalink / raw) To: Jeff King; +Cc: Junio C Hamano, Git mailing list On Fri, Apr 21, 2017 at 10:19 PM, Jeff King <peff@peff.net> wrote: > On Fri, Apr 21, 2017 at 10:14:48PM +0200, SZEDER Gábor wrote: > >> >> This is flexible enough for me, but it's possible somebody would want >> >> this on a per-repo basis. I don't know that we want to read from `git >> >> config`, though, because it's relatively expensive to do so. People who >> >> want per-repo settings are probably better off with a hook that triggers >> >> when they "cd" around, and sets up their preferences. >> >> We could discern between more than just empty vs. non-empty state of >> the environment variable, e.g.: >> >> - if empty/unset, then include "DWIM" suggestions. >> - if set to 'config', then query the 'completion.checkoutNoGuess' >> configuration variable, and omit "DWIM" suggestions if its true. >> - if set to something else, then omit "DWIM" suggestions. >> >> Then users can themselves decide, whether the per-repo configurability >> is worth the overhead of running 'git config'. > > Yep, that would work. I wasn't going to bother with that complexity > unless somebody really wanted it. The important thing is not to paint > ourselves into a corner. By the rules you gave above, it would probably > be fine to extend my patch later to match. But we could also be more > specific (e.g., look for some positive value like "1"). That's fine with me. We should have done this when we introduced env variables controlling the prompt script, we could spare a 'git config' execution in a subshell or two. >> >> @@ -1248,7 +1256,8 @@ _git_checkout () >> >> # check if --track, --no-track, or --no-guess was specified >> >> # if so, disable DWIM mode >> >> local flags="--track --no-track --no-guess" track_opt="--track" >> >> - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then >> >> + if [ -n "$GIT_COMPLETION_CHECKOUT_NO_GUESS" -o \ >> >> + -n "$(__git_find_on_cmdline "$flags")" ]; then >> >> || would be better than '-o', because the former short-circuits when >> the first condition is true, but the latter doesn't. > > Ah, I didn't know that. Usually I use "||", but I thought "-o" was > generally preferred in bash-specific scripts. We definitely want to > short circuit here. No, we use || and && fairly consistently in conditions in Bash scripts. There is no '-o' in the completion or prompt scripts, and there is only a single '-a' in the former, but it only checks two one-letter variables, so it doesn't matter. (Besides, it's from my second ever commit, so it has great sentimental value ;) There are some inconsistencies using 'if [ ... ]' and 'if [[ ... ]]', but oh well. Anyway, v2 looks good to me. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] completion: optionally disable checkout DWIM 2017-04-20 20:12 [PATCH] completion: optionally disable checkout DWIM Jeff King 2017-04-21 5:01 ` Junio C Hamano @ 2017-04-21 7:25 ` Jacob Keller 2017-04-21 20:27 ` [PATCH v2] " Jeff King 2 siblings, 0 replies; 10+ messages in thread From: Jacob Keller @ 2017-04-21 7:25 UTC (permalink / raw) To: Jeff King; +Cc: Git mailing list On Thu, Apr 20, 2017 at 1:12 PM, Jeff King <peff@peff.net> wrote: > When we complete branch names for "git checkout", we also > complete remote branch names that could trigger the DWIM > behavior. Depending on your workflow and project, this can > be either convenient or annoying. > > For instance, my clone of gitster.git contains 74 local > "jk/*" branches, but origin contains another 147. When I > want to checkout a local branch but can't quite remember the > name, tab completion shows me 251 entries. And worse, for a > topic that has been picked up for pu, the upstream branch > name is likely to be similar to mine, leading to a high > probability that I pick the wrong one and accidentally > create a new branch. > > This patch adds a way for the user to tell the completion > code not to include DWIM suggestions for checkout. This can > already be done by typing: > > git checkout --no-guess jk/<TAB> > > but that's rather cumbersome. The downside, of course, is > that you no longer get completion support when you _do_ want > to invoke the DWIM behavior. But depending on your workflow, > that may not be a big loss (for instance, in git.git I am > much more likely to want to detach, so I'd type "git > checkout origin/jk/<TAB>" anyway). > > Signed-off-by: Jeff King <peff@peff.net> > --- > This is flexible enough for me, but it's possible somebody would want > this on a per-repo basis. I don't know that we want to read from `git > config`, though, because it's relatively expensive to do so. People who > want per-repo settings are probably better off with a hook that triggers > when they "cd" around, and sets up their preferences. > I would use this. Completing these can get quite cumbersome to use when I have only a few local branches but many remote ones like in git.git Thanks, Jake ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] completion: optionally disable checkout DWIM 2017-04-20 20:12 [PATCH] completion: optionally disable checkout DWIM Jeff King 2017-04-21 5:01 ` Junio C Hamano 2017-04-21 7:25 ` Jacob Keller @ 2017-04-21 20:27 ` Jeff King 2017-04-24 16:30 ` Brandon Williams 2 siblings, 1 reply; 10+ messages in thread From: Jeff King @ 2017-04-21 20:27 UTC (permalink / raw) To: git; +Cc: SZEDER Gábor, Junio C Hamano When we complete branch names for "git checkout", we also complete remote branch names that could trigger the DWIM behavior. Depending on your workflow and project, this can be either convenient or annoying. For instance, my clone of gitster.git contains 74 local "jk/*" branches, but origin contains another 147. When I want to checkout a local branch but can't quite remember the name, tab completion shows me 251 entries. And worse, for a topic that has been picked up for pu, the upstream branch name is likely to be similar to mine, leading to a high probability that I pick the wrong one and accidentally create a new branch. This patch adds a way for the user to tell the completion code not to include DWIM suggestions for checkout. This can already be done by typing: git checkout --no-guess jk/<TAB> but that's rather cumbersome. The downside, of course, is that you no longer get completion support when you _do_ want to invoke the DWIM behavior. But depending on your workflow, that may not be a big loss (for instance, in git.git I am much more likely to want to detach, so I'd type "git checkout origin/jk/<TAB>" anyway). Signed-off-by: Jeff King <peff@peff.net> --- Compared to v1, this version requires the new variable be set to "1" (to leave more room for later extension), and uses short-circuiting || for the logic. contrib/completion/git-completion.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1150164d5..f977b54d8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -28,6 +28,14 @@ # completion style. For example '!f() { : git commit ; ... }; f' will # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". +# +# You can set the following environment variables to influence the behavior of +# the completion routines: +# +# GIT_COMPLETION_CHECKOUT_NO_GUESS +# +# When set to "1", do not include "DWIM" suggestions in git-checkout +# completion (e.g., completing "foo" when "origin/foo" exists). case "$COMP_WORDBREAKS" in *:*) : great ;; @@ -1248,7 +1256,8 @@ _git_checkout () # check if --track, --no-track, or --no-guess was specified # if so, disable DWIM mode local flags="--track --no-track --no-guess" track_opt="--track" - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] || + [ -n "$(__git_find_on_cmdline "$flags")" ]; then track_opt='' fi __git_complete_refs $track_opt -- 2.13.0.rc0.364.g36b4d8031 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] completion: optionally disable checkout DWIM 2017-04-21 20:27 ` [PATCH v2] " Jeff King @ 2017-04-24 16:30 ` Brandon Williams 0 siblings, 0 replies; 10+ messages in thread From: Brandon Williams @ 2017-04-24 16:30 UTC (permalink / raw) To: Jeff King; +Cc: git, SZEDER Gábor, Junio C Hamano On 04/21, Jeff King wrote: > > When we complete branch names for "git checkout", we also > complete remote branch names that could trigger the DWIM > behavior. Depending on your workflow and project, this can > be either convenient or annoying. > > For instance, my clone of gitster.git contains 74 local > "jk/*" branches, but origin contains another 147. When I > want to checkout a local branch but can't quite remember the > name, tab completion shows me 251 entries. And worse, for a > topic that has been picked up for pu, the upstream branch > name is likely to be similar to mine, leading to a high > probability that I pick the wrong one and accidentally > create a new branch. > > This patch adds a way for the user to tell the completion > code not to include DWIM suggestions for checkout. This can > already be done by typing: > > git checkout --no-guess jk/<TAB> > > but that's rather cumbersome. The downside, of course, is > that you no longer get completion support when you _do_ want > to invoke the DWIM behavior. But depending on your workflow, > that may not be a big loss (for instance, in git.git I am > much more likely to want to detach, so I'd type "git > checkout origin/jk/<TAB>" anyway). > > Signed-off-by: Jeff King <peff@peff.net> May not be relevant to this patch per-say, but is there a way to have the completion for checkout only complete up to a part of remotes/branches? Say a forward-slash '/'. For example git.git has lots of branches which have the form: origin/<initials>/branch-name. It would be convenient if when I type: git checkout <TAB> Instead of getting a long list of 2k or so branch names that instead I would get see the remote's name e.g. 'origin/' kind of like vanilla directory completion. This way, unless I'm actually interested in the remote, I don't see the thousands of branches related to it. -- Brandon Williams ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-04-24 16:30 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-04-20 20:12 [PATCH] completion: optionally disable checkout DWIM Jeff King 2017-04-21 5:01 ` Junio C Hamano 2017-04-21 5:03 ` Jeff King 2017-04-21 5:30 ` Junio C Hamano 2017-04-21 20:14 ` SZEDER Gábor 2017-04-21 20:19 ` Jeff King 2017-04-22 17:32 ` SZEDER Gábor 2017-04-21 7:25 ` Jacob Keller 2017-04-21 20:27 ` [PATCH v2] " Jeff King 2017-04-24 16:30 ` Brandon Williams
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).