From: Jon Seymour Date: Sat, 23 Apr 2011 07:22:40 GMT Subject: [PATCH 11/23] Introduce --commit-exists. Message-ID: <1303543372-77843-12-git-send-email-jon.seymour@gmail.com> In-Reply-To: <1303543372-77843-1-git-send-email-jon.seymour@gmail.com> tweak commit --- Documentation/git-test.txt | 2 ++ git-conditions-lib.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/Documentation/git-test.txt b/Documentation/git-test.txt index 259a04c..9a4e06f 100644 --- a/Documentation/git-test.txt +++ b/Documentation/git-test.txt @@ -82,6 +82,8 @@ CONDITIONS Tests if the specified tag does (not) exist. '--ref-exists'|'--not-ref-exists tag':: Tests if the specified reference does (not) exist. +'--commit-exists'|'--not-commit-exists commit':: + Tests if the specified commit does (not) exist. EXTENDING THE CONDITION LIBRARY ------------------------------- diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh index c21d669..af376d1 100644 --- a/git-conditions-lib.sh +++ b/git-conditions-lib.sh @@ -111,5 +111,16 @@ check_ref_exists_1() fi } +check_commit_exists_1() +{ + if test "$(git cat-file -t "$1")" = 'commit' + then + echo "Commit '$1' exists." + else + echo "Commit '$1' does not exist." + false + fi +} + fi -- 1.7.5.rc1.23.g7f622