git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 11/12] tests for checkout [--full|--path]
Date: Wed, 23 Jul 2008 21:57:59 +0700	[thread overview]
Message-ID: <20080723145759.GA29166@laptop> (raw)


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

                 reply	other threads:[~2008-07-23 14:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080723145759.GA29166@laptop \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /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).