# [PATCH v2] t7012: Implement test for git-checkout

2 messages from 2016-03-25 to 2016-03-25. Participants: Chhatoi Pritam Baral.
Thread: https://gitlist.dev/t/41831

## Chhatoi Pritam Baral, 2016-03-25 23:34

Subject: [PATCH v2] t7012: Implement test for git-checkout
Message-ID: <56F5CAEF.9070906@gmail.com>
URL: https://gitlist.dev/e/56F5CAEF.9070906%40gmail.com

```
Previously a TODO; add a test for git-checkout skipping a
file with the skip-worktree bit set.

Signed-off-by: Chhatoi Pritam Baral <chhatoipritam@gmail.com>
---

This is a microproject for my GSoC '16 application.

Thanks, Torsten, for pointing out my mistakes. :)
It was my first time sending patches in mail (and not as attachments).

 t/t7012-skip-worktree-writing.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/t/t7012-skip-worktree-writing.sh
b/t/t7012-skip-worktree-writing.sh
index 9ceaa40..276f076 100755
--- a/t/t7012-skip-worktree-writing.sh
+++ b/t/t7012-skip-worktree-writing.sh
@@ -141,6 +141,16 @@ test_expect_success 'git-clean, dirty case' '
 #TODO test_expect_failure 'git-apply removes file' false
 #TODO test_expect_failure 'git-mv to skip-worktree' false
 #TODO test_expect_failure 'git-mv from skip-worktree' false
-#TODO test_expect_failure 'git-checkout' false
+
+test_expect_success 'git-checkout ignores skip-worktree file' '
+	echo >1 &&
+	git commit -m "Add files" &&
+	echo dirty >1 &&
+	echo dirty >2 &&
+	git update-index --skip-worktree 1 &&
+	git checkout -- . &&
+	grep -q dirty 1 &&
+	test_must_fail grep -q dirty 2
+'
  test_done
-- 
2.7.4

```

## Chhatoi Pritam Baral, 2016-03-25 23:39

Subject: Re: [PATCH v2] t7012: Implement test for git-checkout
Message-ID: <56F5CC3A.90500@gmail.com>
URL: https://gitlist.dev/e/56F5CC3A.90500%40gmail.com
In-Reply-To: <56F5CAEF.9070906@gmail.com>

```


On 03/26/2016 05:04 AM, Chhatoi Pritam Baral wrote:
> Previously a TODO; add a test for git-checkout skipping a
> file with the skip-worktree bit set.
>
> Signed-off-by: Chhatoi Pritam Baral <chhatoipritam@gmail.com>
> ---
>
> This is a microproject for my GSoC '16 application.
>
> Thanks, Torsten, for pointing out my mistakes. :)
> It was my first time sending patches in mail (and not as attachments).
>
>  t/t7012-skip-worktree-writing.sh | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/t/t7012-skip-worktree-writing.sh
> b/t/t7012-skip-worktree-writing.sh
> index 9ceaa40..276f076 100755
> --- a/t/t7012-skip-worktree-writing.sh
> +++ b/t/t7012-skip-worktree-writing.sh
> @@ -141,6 +141,16 @@ test_expect_success 'git-clean, dirty case' '
>  #TODO test_expect_failure 'git-apply removes file' false
>  #TODO test_expect_failure 'git-mv to skip-worktree' false
>  #TODO test_expect_failure 'git-mv from skip-worktree' false
> -#TODO test_expect_failure 'git-checkout' false
> +
> +test_expect_success 'git-checkout ignores skip-worktree file' '
> +	echo >1 &&
> +	git commit -m "Add files" &&
> +	echo dirty >1 &&
> +	echo dirty >2 &&
> +	git update-index --skip-worktree 1 &&
> +	git checkout -- . &&
> +	grep -q dirty 1 &&
> +	test_must_fail grep -q dirty 2
As Eric mentioned on another thread, test_must_fail needs replacing with
'!'.

I'll just wait a while, let the two thread collect responses before I
begin a v3 thread.
> +'
>   test_done

```
