git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jacob Keller <jacob.keller@gmail.com>
Subject: [PATCH v3 07/16] completion: add tests showing subpar switch/checkout --orphan logic
Date: Thu, 28 May 2020 11:10:39 -0700	[thread overview]
Message-ID: <20200528181048.3509470-8-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20200528181048.3509470-1-jacob.e.keller@intel.com>

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

Similar to -c/-C, --orphan takes an argument which is the branch name to
use. We ought to complete this branch name using similar rules as to how
we complete new branch names for -c/-C and -b/-B. Namely, limit the
total number of options provided by completing to the local branches.

Additionally, git switch --orphan does not take any start point and will
always create using the empty-tree. Thus, after the branch name is
completed, git switch --orphan should not complete any references.

Add test cases showing the expected behavior of --orphan, for both the
argument and starting point.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 t/t9902-completion.sh | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 63daf43b89ec..e4c48b20d39d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1688,6 +1688,45 @@ test_expect_failure 'git checkout - for -B with --no-track, complete local branc
 	EOF
 '
 
+#TODO: --orphan argument completion should not include all references
+test_expect_failure 'git switch - with --orphan completes local branch names and unique remote branch names' '
+	test_completion "git switch --orphan " <<-\EOF
+	branch-in-other Z
+	master Z
+	master-in-other Z
+	matching-branch Z
+	EOF
+'
+
+#TODO: switch --orphan does not take a start-point and thus has nothing to complete
+test_expect_failure 'git switch - --orphan with branch already provided completes nothing else' '
+	test_completion "git switch --orphan master " <<-\EOF
+
+	EOF
+'
+
+#TODO: --orphan argument completion should not include all references
+test_expect_failure 'git checkout - with --orphan completes local branch names and unique remote branch names' '
+	test_completion "git checkout --orphan " <<-\EOF
+	branch-in-other Z
+	master Z
+	master-in-other Z
+	matching-branch Z
+	EOF
+'
+
+#TODO: checkout --orphan start-point completion should not included DWIM remote unique branch names
+test_expect_failure 'git checkout - --orphan with branch already provided completes local refs for a start-point' '
+	test_completion "git checkout --orphan master " <<-\EOF
+	HEAD Z
+	master Z
+	matching-branch Z
+	matching-tag Z
+	other/branch-in-other Z
+	other/master-in-other Z
+	EOF
+'
+
 test_expect_success 'teardown after ref completion' '
 	git branch -d matching-branch &&
 	git tag -d matching-tag &&
-- 
2.25.2


  parent reply	other threads:[~2020-05-28 18:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jacob Keller [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200528181048.3509470-8-jacob.e.keller@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.keller@gmail.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).