t3404: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.  Add a use of $EMPTY_TREE instead of a
hard-coded value.  Remove a comment about hard-coded hashes which is no
longer applicable.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2019-08-18 19:16:38 +00:00 committed by Junio C Hamano
parent b99bfc7a6c
commit 4dd1b5f90f

View file

@ -29,9 +29,6 @@ Initial setup:
. "$TEST_DIRECTORY"/lib-rebase.sh
# WARNING: Modifications to the initial repository can change the SHA ID used
# in the expect2 file for the 'stop on conflicting pick' test.
test_expect_success 'setup' '
test_commit A file1 &&
test_commit B file1 &&
@ -233,25 +230,28 @@ test_expect_success 'exchange two commits' '
set_fake_editor &&
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
test G = $(git cat-file commit HEAD | sed -ne \$p)
test G = $(git cat-file commit HEAD | sed -ne \$p) &&
blob1=$(git rev-parse --short HEAD^:file1) &&
blob2=$(git rev-parse --short HEAD:file1) &&
commit=$(git rev-parse --short HEAD)
'
test_expect_success 'stop on conflicting pick' '
cat >expect <<-\EOF &&
cat >expect <<-EOF &&
diff --git a/file1 b/file1
index f70f10e..fd79235 100644
index $blob1..$blob2 100644
--- a/file1
+++ b/file1
@@ -1 +1 @@
-A
+G
EOF
cat >expect2 <<-\EOF &&
cat >expect2 <<-EOF &&
<<<<<<< HEAD
D
=======
G
>>>>>>> 5d18e54... G
>>>>>>> $commit... G
EOF
git tag new-branch1 &&
set_fake_editor &&
@ -1003,7 +1003,7 @@ test_expect_success 'rebase -i --root temporary sentinel commit' '
git checkout B &&
set_fake_editor &&
test_must_fail env FAKE_LINES="2" git rebase -i --root &&
git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
git cat-file commit HEAD | grep "^tree $EMPTY_TREE" &&
git rebase --abort
'
@ -1161,7 +1161,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
test_expect_code 1 grep " emp" error
'
test_expect_success 'short SHA-1 setup' '
test_expect_success SHA1 'short SHA-1 setup' '
test_when_finished "git checkout master" &&
git checkout --orphan collide &&
git rm -rf . &&
@ -1173,7 +1173,7 @@ test_expect_success 'short SHA-1 setup' '
)
'
test_expect_success 'short SHA-1 collide' '
test_expect_success SHA1 'short SHA-1 collide' '
test_when_finished "reset_rebase && git checkout master" &&
git checkout collide &&
(