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