mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
tests: move test_cmp_rev to test-lib-functions
A function for checking that two given parameters refer to the same revision was defined in several places, so move the definition to test-lib-functions.sh instead. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b3cf6f3b8d
commit
5d77298d08
@ -32,32 +32,24 @@ test_expect_success 'setup' '
|
||||
#
|
||||
# and 'side' should be the last branch
|
||||
|
||||
test_rev_equivalent () {
|
||||
|
||||
git rev-parse "$1" > expect &&
|
||||
git rev-parse "$2" > output &&
|
||||
test_cmp expect output
|
||||
|
||||
}
|
||||
|
||||
test_expect_success '@{-1} works' '
|
||||
test_rev_equivalent side @{-1}
|
||||
test_cmp_rev side @{-1}
|
||||
'
|
||||
|
||||
test_expect_success '@{-1}~2 works' '
|
||||
test_rev_equivalent side~2 @{-1}~2
|
||||
test_cmp_rev side~2 @{-1}~2
|
||||
'
|
||||
|
||||
test_expect_success '@{-1}^2 works' '
|
||||
test_rev_equivalent side^2 @{-1}^2
|
||||
test_cmp_rev side^2 @{-1}^2
|
||||
'
|
||||
|
||||
test_expect_success '@{-1}@{1} works' '
|
||||
test_rev_equivalent side@{1} @{-1}@{1}
|
||||
test_cmp_rev side@{1} @{-1}@{1}
|
||||
'
|
||||
|
||||
test_expect_success '@{-2} works' '
|
||||
test_rev_equivalent master @{-2}
|
||||
test_cmp_rev master @{-2}
|
||||
'
|
||||
|
||||
test_expect_success '@{-3} fails' '
|
||||
|
@ -29,12 +29,6 @@ Initial setup:
|
||||
|
||||
. "$TEST_DIRECTORY"/lib-rebase.sh
|
||||
|
||||
test_cmp_rev () {
|
||||
git rev-parse --verify "$1" >expect.rev &&
|
||||
git rev-parse --verify "$2" >actual.rev &&
|
||||
test_cmp expect.rev actual.rev
|
||||
}
|
||||
|
||||
set_fake_editor
|
||||
|
||||
# WARNING: Modifications to the initial repository can change the SHA ID used
|
||||
|
@ -11,12 +11,6 @@ test_description='test cherry-pick and revert with conflicts
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_cmp_rev () {
|
||||
git rev-parse --verify "$1" >expect.rev &&
|
||||
git rev-parse --verify "$2" >actual.rev &&
|
||||
test_cmp expect.rev actual.rev
|
||||
}
|
||||
|
||||
pristine_detach () {
|
||||
git checkout -f "$1^0" &&
|
||||
git read-tree -u --reset HEAD &&
|
||||
|
@ -5,15 +5,11 @@ test_description='test cherry-picking many commits'
|
||||
. ./test-lib.sh
|
||||
|
||||
check_head_differs_from() {
|
||||
head=$(git rev-parse --verify HEAD) &&
|
||||
arg=$(git rev-parse --verify "$1") &&
|
||||
test "$head" != "$arg"
|
||||
! test_cmp_rev HEAD "$1"
|
||||
}
|
||||
|
||||
check_head_equals() {
|
||||
head=$(git rev-parse --verify HEAD) &&
|
||||
arg=$(git rev-parse --verify "$1") &&
|
||||
test "$head" = "$arg"
|
||||
test_cmp_rev HEAD "$1"
|
||||
}
|
||||
|
||||
test_expect_success setup '
|
||||
|
@ -24,12 +24,6 @@ pristine_detach () {
|
||||
git clean -d -f -f -q -x
|
||||
}
|
||||
|
||||
test_cmp_rev () {
|
||||
git rev-parse --verify "$1" >expect.rev &&
|
||||
git rev-parse --verify "$2" >actual.rev &&
|
||||
test_cmp expect.rev actual.rev
|
||||
}
|
||||
|
||||
test_expect_success setup '
|
||||
git config advice.detachedhead false &&
|
||||
echo unrelated >unrelated &&
|
||||
|
@ -676,9 +676,7 @@ test_expect_success 'bisect fails if tree is broken on trial commit' '
|
||||
check_same()
|
||||
{
|
||||
echo "Checking $1 is the same as $2" &&
|
||||
git rev-parse "$1" > expected.same &&
|
||||
git rev-parse "$2" > expected.actual &&
|
||||
test_cmp expected.same expected.actual
|
||||
test_cmp_rev "$1" "$2"
|
||||
}
|
||||
|
||||
test_expect_success 'bisect: --no-checkout - start commit bad' '
|
||||
|
@ -602,6 +602,13 @@ test_cmp() {
|
||||
$GIT_TEST_CMP "$@"
|
||||
}
|
||||
|
||||
# Tests that its two parameters refer to the same revision
|
||||
test_cmp_rev () {
|
||||
git rev-parse --verify "$1" >expect.rev &&
|
||||
git rev-parse --verify "$2" >actual.rev &&
|
||||
test_cmp expect.rev actual.rev
|
||||
}
|
||||
|
||||
# Print a sequence of numbers or letters in increasing order. This is
|
||||
# similar to GNU seq(1), but the latter might not be available
|
||||
# everywhere (and does not do letters). It may be used like:
|
||||
|
Loading…
Reference in New Issue
Block a user