threads / patch / 14625

patch, 12 partstests for checkout [--full|--path]

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

## tl;dr

One message between Jul 23, 2008 and Jul 23, 2008. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Nguyễn Thái Ngọc Duy· Jul 23, 2008, 14:57 UTC · lore
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
Show changes to t/t2010-checkout-sparse.sh +71 −0
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

← back to recent threads