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

[PATCH 11/12] tests for checkout [--full|--path]

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 23, 2008, 14:57 UTC
Message-ID
<20080723145759.GA29166@laptop>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t2010-checkout-sparse.sh |   71 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100755 t/t2010-checkout-sparse.sh
diff --git a/t/t2010-checkout-sparse.sh b/t/t2010-checkout-sparse.sh
new file mode 100755
index 0000000..5bb82ae
--- /dev/null
+++ b/t/t2010-checkout-sparse.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+test_description='sparse checkout'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	mkdir work1 work2 work3
+	touch one two three
+	touch work1/one work2/two work3/three
+	git add one work1/one
+	git commit -m work1
+	git add two work2/two
+	git commit -m work2
+	git add three work3/three
+	git commit -m work3
+'
+
+test_expect_success '--full on no-sparse checkout' '
+	git checkout --full
+'
+
+test_expect_success '--full and --path incompatible' '
+	test_must_fail git checkout --full --path=work1
+'
+
+test_expect_success 'limit worktree to work1 and work2' '
+	git checkout --path=work1:work2 &&
+	test work1:work2 = "$(git rev-parse --show-sparse-prefix)" &&
+	test -f work1/one &&
+	test -f work2/two &&
+	! test -f work3/three
+'
+
+test_expect_success 'update worktree to work2 and work3' '
+	git checkout --path=work2:work3 &&
+	test work2:work3 = "$(git rev-parse --show-sparse-prefix)" &&
+	! test -f work1/one &&
+	test -f work2/two &&
+	test -f work3/three
+'
+
+test_expect_success 'update sparse prefix with modification' '
+	echo modified >> work2/two &&
+	git checkout --path=work1:work2 &&
+	test work1:work2 = "$(git rev-parse --show-sparse-prefix)" &&
+	test -f work1/one &&
+	test -f work2/two &&
+	! test -f work3/three &&
+	grep -q modified work2/two
+'
+
+test_expect_success 'update sparse should not lose modification' '
+	! git checkout --path=work1:work3 &&
+	test work1:work2 = "$(git rev-parse --show-sparse-prefix)" &&
+	test -f work1/one &&
+	test -f work2/two &&
+	! test -f work3/three &&
+	grep -q modified work2/two
+'
+
+test_expect_success 'exit sparse checkout' '
+	git checkout --full &&
+	test -z "$(git rev-parse --show-sparse-prefix)" &&
+	test -f work1/one &&
+	test -f work2/two &&
+	test -f work3/three &&
+	test one
+'
+
+test_done
-- 
1.5.5.GIT
Message 1 of 1 in “tests for checkout [--full|--path]”
  1. 11/12 tests for checkout [--full|--path]Nguyễn Thái Ngọc Duy, Jul 23, 2008

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.