[PATCH 04/23] Introduce --untracked.
Add tests for --untracked, --not-untracked.
---
Documentation/git-test.txt | 3 ++-
git-conditions-lib.sh | 11 +++++++++++
t/t1520-test.sh | 24 ++++++++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-test.txt b/Documentation/git-test.txt
index 9264c90..9f6a4c3 100644
--- a/Documentation/git-test.txt
+++ b/Documentation/git-test.txt
@@ -68,7 +68,8 @@ CONDITIONS
Tests if there are (not) any unstaged changes in the working tree.
'--staged'|'--not-staged'::
Tests if there are (not) any staged changes in the index.
-
+'--untracked'|'--not-untracked'::
+ Tests if there are (not) any untracked files in the working tree.
EXTENDING THE CONDITION LIBRARY
-------------------------------
diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh
index 55b4131..7198e6a 100644
--- a/git-conditions-lib.sh
+++ b/git-conditions-lib.sh
@@ -30,5 +30,16 @@ check_staged_0()
fi
}
+check_untracked_0()
+{
+ if test $(git ls-files -o --exclude-standard | wc -l) -ne 0
+ then
+ echo "There are untracked files."
+ else
+ echo "There are no untracked files."
+ false
+ fi
+}
+
fi
diff --git a/t/t1520-test.sh b/t/t1520-test.sh
index 7438f93..ebff63c 100755
--- a/t/t1520-test.sh
+++ b/t/t1520-test.sh
@@ -250,6 +250,30 @@ test_expect_success 'git test --staged # when there are only unstaged files' \
git test --not-staged
'
+test_expect_success 'git test --untracked # should fail' \
+'
+ test_must_fail git test --untracked
+'
+
+test_expect_success 'git test --not-untracked' \
+'
+ git test --not-untracked
+'
+
+test_expect_success 'git test --untracked # when there are untracked files' \
+'
+ test_when_finished "git clean -fd" &&
+ :> untracked &&
+ git test --untracked
+'
+
+test_expect_success 'git test --not-untracked # when there are untracked files - should fail' \
+'
+ test_when_finished "git clean -fd" &&
+ :> untracked &&
+ test_must_fail git test --not-untracked
+'
+
'
test_when_finished "git reset --hard HEAD && git checkout master" &&
git test --not-staged --not-unstaged &&
--
1.7.5.rc1.23.g7f622