[PATCH 12/23] Introduce --checked-out

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]