[PATCH 12/23] Introduce --checked-out
---
Documentation/git-test.txt | 2 ++
git-conditions-lib.sh | 14 ++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-test.txt b/Documentation/git-test.txt
index 9a4e06f..f76aa38 100644
--- a/Documentation/git-test.txt
+++ b/Documentation/git-test.txt
@@ -84,6 +84,8 @@ CONDITIONS
Tests if the specified reference does (not) exist.
'--commit-exists'|'--not-commit-exists commit'::
Tests if the specified commit does (not) exist.
+'--checked-out'|'--not-checked-out branch'::
+ Tests if the specified branch is (not) checked out.
EXTENDING THE CONDITION LIBRARY
-------------------------------
diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh
index af376d1..3eccc19 100644
--- a/git-conditions-lib.sh
+++ b/git-conditions-lib.sh
@@ -122,5 +122,19 @@ check_commit_exists_1()
fi
}
+check_checked_out_1()
+{
+ branch="$(git rev-parse --quiet --symbolic-full-name --verify "$1")"
+ headref="$(git symbolic-ref HEAD)"
+ if test "${headref}" = "${branch}" -a -n "${branch}"
+ then
+ echo "'$1' is checked out."
+ else
+ echo "'$1' is not checked out."
+ false
+ fi
+
+}
+
fi
--
1.7.5.rc1.23.g7f622