Skip to contentSkip to conversation

t7012: Implement test for git-checkout

PATCH Superseded Chhatoi Pritam Baral 3 participants 3 messages Jun 15, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t7012: Implement test for git-checkout

Previously a TODO, this patch adds a test for git-checkout skipping a file with the
skip-worktree bit set.

I'm doing this as a microproject for my GSoC '16 application.

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

b/t/t7012-skip-worktree-writing.sh
index 9ceaa40..d5b42d6 100755

t/t7012-skip-worktree-writing.sh +11 -1
@@ -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
Signature · 1 line
2.7.4
#1 lore raw

On 2016-03-25 18.36, Chhatoi Pritam Baral wrote:
Thanks for working on Git.
Some comments inline.

Quoted 3 lines

Previously a TODO, this patch adds a test for git-checkout skipping a file with the
skip-worktree bit set.

Micro-nit: the "this patch ..." may be written shorter:

Quoted 5 lines

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

I'm doing this as a microproject for my GSoC '16 application.

This info is good to have, but doesn't need to stay forever in the commit message. It may be below (see XXX)

Quoted 3 lines

---

XXX Add additional info here.

Quoted 9 lines
 t/t7012-skip-worktree-writing.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
t/t7012-skip-worktree-writing.sh +0 -0
index 9ceaa40..d5b42d6 100755

t/t7012-skip-worktree-writing.sh test_expect_success 'git-clean, dirty case' ' · line 146

Quoted 7 lines
t/t7012-skip-worktree-writing.sh +3 -1
@@ -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 &&

Style: No space after the '>', like this:
echo >1 &&

Quoted 10 lines
t/t7012-skip-worktree-writing.sh +8 -0
+	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 lore raw
In reply to Chhatoi Pritam Baral
Quoted 2 lines · Chhatoi Pritam Baral

Previously a TODO, this patch adds a test for git-checkout skipping a file with the skip-worktree bit set.

In addition to Torsten's comments...

Quoted 7 lines
t/t7012-skip-worktree-writing.sh +0 -1
@@ -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

t/t7012-skip-worktree-writing.sh test_expect_success 'git-clean, dirty case' ' · line 153

Quoted 10 lines
t/t7012-skip-worktree-writing.sh +10 -0
+
+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_must_fail is for git commands; for system commands, just use '!' (t/README explains the rationale).

! grep -q dirty 2

Quoted 2 lines
t/t7012-skip-worktree-writing.sh +1 -0
+'
  test_done