git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3 00/16] improve switch/checkout completion
@ 2020-05-28 18:10 Jacob Keller
  2020-05-28 18:10 ` [PATCH v3 01/16] completion: add test showing subpar git switch completion Jacob Keller
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Jacob Keller @ 2020-05-28 18:10 UTC (permalink / raw)
  To: git; +Cc: Jonathan Nieder, Junio C Hamano, Jacob Keller

From: Jacob Keller <jacob.keller@gmail.com>

Recently I noticed that the completion support for git switch is subpar, and
can lead to frustrating moments. Specifically the difference between
completing `git switch` vs `git switch --track`:

  $git switch <TAB>
  Display all 784 possibilities? (y or n)
  <list of all references and DWIM remotes>

Notice that git switch will complete basically all references, including
things like HEAD, and remote references like "origin/master". Many of these
values are useless and clutter the output. It's not too bad, but could be
somewhat improved. At least it still completes useful words.

However, the same cannot be said for --track:

  $git switch --track<TAB>
  jk-refactor-git-switch-completion master

Notice that with --track, we suddenly start completing only local branches.
Not only does this severely limit what we complete, it includes *only*
useless words. This leads to incredibly frustrating moments, as I often use
"git switch --track remote/<TAB>" to create tracking branches. I found
myself often having to backspace --track just to complete what I wanted and
then re-add it.

The primary original motivation of this series was to improve the handling
of track. Several other issues were discovered, and I attempt to improve
pretty much every mode of switch.

The first few patches simply add new test cases, most of which fail. This is
done in order to give time to fully explain what I believe is deficient
about the specific case.

Following these patches are some cleanup improvements to remove some
confusing terminology and introduce new functions that will be useful to
improve the completion functions.

Finally, several patches which improve completion follow. By the end,
completion for both git switch and git checkout should be more useful and
more aware of the intention of the current argument being completed.

A patch to initially fix just the --track behavior was posted at
https://lore.kernel.org/git/20200422201541.3766173-1-jacob.e.keller@intel.com/

This original patch was reviewed by Jonathan Nieder, and he suggested
further improvements, which led to v1 of this series
https://lore.kernel.org/git/20200425022045.1089291-1-jacob.e.keller@intel.com/

This was further reviewed, and some issues with the handling of completing
the argument to -c/-C were brought up by Junio, which I then improved in v2
https://lore.kernel.org/git/20200527113831.3294409-1-jacob.e.keller@intel.com/

Junio mentioned that the commit messages for this v2 series were difficult
to follow. I have split the tests from the implementation patches and
re-written the commit messages. Hopefully this now better highlights the
places where completion isn't behaving as I would expect.

Once again, given the nature of the rework I did not find a suitable
range-diff that expressed the evolution from v2 to v3, so I haven't included
it here.

I would really like opinions on whether the suggested -c/-C argument
completion makes sense. I opted to limit it to complete local branch names,
and optionally the unique remote branch names. I'm open to alternative
suggestions if anyone has a better suggestion? I had thought perhaps also
some users might wish to see tags, if they have branches named after tags or
similar.. I don't think completing all references makes sense: branches with
remote prefixes in their name would be confusing.

Jacob Keller (16):
  completion: add test showing subpar git switch completion
  completion: add tests showing subpar DWIM logic for switch/checkout
  completion: add tests showing subar checkout --detach logic
  completion: add tests showing subpar switch/checkout --track logic
  completion: add tests showing subpar -c/-C startpoint completion
  completion: add tests showing subpar -c/C argument completion
  completion: add tests showing subpar switch/checkout --orphan logic
  completion: replace overloaded track term for __git_complete_refs
  completion: extract function __git_dwim_remote_heads
  completion: perform DWIM logic directly in __git_complete_refs
  completion: improve handling of DWIM mode for switch/checkout
  completion: improve completion for git switch with no options
  completion: improve handling of --detach in checkout
  completion: improve handling of --track in switch/checkout
  completion: improve handling of -c/-C and -b/-B in switch/checkout
  completion: improve handling of --orphan option of switch/checkout

 contrib/completion/git-completion.bash | 252 +++++++++++---
 t/t9902-completion.sh                  | 456 +++++++++++++++++++++++++
 2 files changed, 669 insertions(+), 39 deletions(-)

-- 
2.25.2

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

end of thread, other threads:[~2020-05-28 18:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 18:10 [PATCH v3 00/16] improve switch/checkout completion Jacob Keller
2020-05-28 18:10 ` [PATCH v3 01/16] completion: add test showing subpar git switch completion Jacob Keller
2020-05-28 18:10 ` [PATCH v3 02/16] completion: add tests showing subpar DWIM logic for switch/checkout Jacob Keller
2020-05-28 18:10 ` [PATCH v3 03/16] completion: add tests showing subar checkout --detach logic Jacob Keller
2020-05-28 18:10 ` [PATCH v3 04/16] completion: add tests showing subpar switch/checkout --track logic Jacob Keller
2020-05-28 18:10 ` [PATCH v3 05/16] completion: add tests showing subpar -c/-C startpoint completion Jacob Keller
2020-05-28 18:10 ` [PATCH v3 06/16] completion: add tests showing subpar -c/C argument completion Jacob Keller
2020-05-28 18:10 ` [PATCH v3 07/16] completion: add tests showing subpar switch/checkout --orphan logic Jacob Keller
2020-05-28 18:10 ` [PATCH v3 08/16] completion: replace overloaded track term for __git_complete_refs Jacob Keller
2020-05-28 18:10 ` [PATCH v3 09/16] completion: extract function __git_dwim_remote_heads Jacob Keller
2020-05-28 18:10 ` [PATCH v3 10/16] completion: perform DWIM logic directly in __git_complete_refs Jacob Keller
2020-05-28 18:10 ` [PATCH v3 11/16] completion: improve handling of DWIM mode for switch/checkout Jacob Keller
2020-05-28 18:10 ` [PATCH v3 12/16] completion: improve completion for git switch with no options Jacob Keller
2020-05-28 18:10 ` [PATCH v3 13/16] completion: improve handling of --detach in checkout Jacob Keller
2020-05-28 18:10 ` [PATCH v3 14/16] completion: improve handling of --track in switch/checkout Jacob Keller
2020-05-28 18:10 ` [PATCH v3 15/16] completion: improve handling of -c/-C and -b/-B " Jacob Keller
2020-05-28 18:10 ` [PATCH v3 16/16] completion: improve handling of --orphan option of switch/checkout Jacob Keller

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).