tweak ref --- 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 69c8710..259a04c 100644 --- a/Documentation/git-test.txt +++ b/Documentation/git-test.txt @@ -80,6 +80,8 @@ CONDITIONS Tests if the specified branch does (not) exist. '--tag-exists'|'--not-tag-exists tag':: Tests if the specified tag does (not) exist. +'--ref-exists'|'--not-ref-exists tag':: + Tests if the specified reference does (not) exist. EXTENDING THE CONDITION LIBRARY ------------------------------- diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh index 93a916a..c21d669 100644 --- a/git-conditions-lib.sh +++ b/git-conditions-lib.sh @@ -99,5 +99,17 @@ check_tag_exists_1() fi } +check_ref_exists_1() +{ + symbolic=$(git rev-parse --quiet --symbolic-full-name --verify "$1") + if test "${symbolic#refs/}" != "${symbolic}" + then + echo "Reference '$1' exists." + else + echo "Reference '$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