[PATCH 08/23] Introduce --branch-exists

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

 



tweak branch

tweak branch
---
 Documentation/git-test.txt |    2 ++
 git-conditions-lib.sh      |   12 ++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-test.txt b/Documentation/git-test.txt
index 501725c..ea54d20 100644
--- a/Documentation/git-test.txt
+++ b/Documentation/git-test.txt
@@ -76,6 +76,8 @@ CONDITIONS
         Tests if a rebase is (not) in progress.
 '--detached'|'--not-detached'::
 	Tests if the head is (not) detached.
+'--branch-exists'|'--not-branch-exists branch'::
+        Tests if the specified branch does (not) exist.				    
 
 EXTENDING THE CONDITION LIBRARY
 -------------------------------
diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh
index 34de896..5d7a7f8 100644
--- a/git-conditions-lib.sh
+++ b/git-conditions-lib.sh
@@ -75,5 +75,17 @@ check_detached_0()
 	fi
 }
 
+check_branch_exists_1()
+{
+	symbolic=$(git rev-parse --quiet --symbolic-full-name --verify "$1")
+ 	if test "${symbolic#refs/heads/}" != "${symbolic}"
+	then
+		echo "Branch '$1' exists."
+	else
+		echo "Branch '$1' does not exist."
+		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]