[PATCH 15/23] Introduce --same
---
Documentation/git-test.txt | 2 ++
git-conditions-lib.sh | 10 ++++++++++
t/t1520-test.sh | 8 ++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-test.txt b/Documentation/git-test.txt
index 6709fdd..b7c3161 100644
--- a/Documentation/git-test.txt
+++ b/Documentation/git-test.txt
@@ -90,6 +90,8 @@ CONDITIONS
Tests if the first commit is (not) reachable from the second.
'--tree-same'|'--not-tree-same' first second::
Tests if the first commit is (not) tree-same to the second commit.
+'--same'|'--not-same' first second::
+ Tests if the first object has (does not have) the same SHA1 has as the second object.
EXTENDING THE CONDITION LIBRARY
-------------------------------
diff --git a/git-conditions-lib.sh b/git-conditions-lib.sh
index 2b7a5d1..ec9b516 100644
--- a/git-conditions-lib.sh
+++ b/git-conditions-lib.sh
@@ -162,5 +162,15 @@ check_tree_same_2()
}
+check_same_2()
+{
+ if test "$(git rev-parse "$1")" = "$(git rev-parse "$2")"
+ then
+ echo "'$1' is the same as '$2'."
+ else
+ echo "'$1' is not the same as '$2'."
+ false
+ fi
+}
fi
diff --git a/t/t1520-test.sh b/t/t1520-test.sh
index 1fd5122..1d0776d 100755
--- a/t/t1520-test.sh
+++ b/t/t1520-test.sh
@@ -408,4 +408,12 @@ test_expect_success 'tree-same' \
'
+test_expect_success 'same' \
+'
+ git test \
+ --same master HEAD \
+ --not-same D D1 \
+ --not-same C D
+'
+
test_done
--
1.7.5.rc1.23.g7f622