git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] t2060: add a test for switch with --orphan and --discard-changes

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 21, 2020, 02:07 UTC
Message-ID
<20200521020712.1620993-3-sandals@crustytoothpaste.net>
In-Reply-To
<20200521020712.1620993-1-sandals@crustytoothpaste.net>

We have several code paths in the checkout code which are traversed only in this case, due to switch having different defaults from checkout. Let's add a test that the combination of options works and produces the expected behavior.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t2060-switch.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh
index f9efa29dfb..2c1b8c0d6d 100755
--- a/t/t2060-switch.sh
+++ b/t/t2060-switch.sh
@@ -68,6 +68,14 @@ test_expect_success 'new orphan branch from empty' '
 	test_cmp expected tracked-files
 '
 
+test_expect_success 'orphan branch works with --discard-changes' '
+	test_when_finished git switch master &&
+	echo foo >foo.txt &&
+	git switch --discard-changes --orphan new-orphan2 &&
+	git ls-files >tracked-files &&
+	test_must_be_empty tracked-files
+'
+
 test_expect_success 'switching ignores file of same branch name' '
 	test_when_finished git switch master &&
 	: >first-branch &&
Previous: brian m. carlsonNext: Derrick Stolee
Message 15 of 16 in “Git Test Coverage Report (v2.27.0-rc0)”
  1. Derrick StoleeMay 15, 2020
  2. Derrick StoleeMay 19, 2020
  3. René ScharfeMay 19, 2020
  4. brian m. carlsonMay 19, 2020
  5. brian m. carlsonMay 20, 2020
  6. t4067: make rename detection test output raw diffJonathan Tan, May 19, 2020
  7. Derrick StoleeMay 19, 2020
  8. 1/1 builtin/checkout: simplify metadata initializationbrian m. carlson, May 20, 2020
  9. Junio C HamanoMay 20, 2020
  10. brian m. carlsonMay 20, 2020
  11. 0/2 Improve Fix code coverage for checkoutbrian m. carlson, May 21, 2020
  12. 1/2 builtin/checkout: simplify metadata initializationbrian m. carlson, May 21, 2020
  13. Junio C HamanoMay 21, 2020
  14. brian m. carlsonMay 23, 2020
  15. 2/2 t2060: add a test for switch with --orphan and --discard-changesbrian m. carlson, May 21, 2020
  16. Derrick StoleeMay 21, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.