]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3404: abstract away SHA-1-specific constants
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 18 Aug 2019 19:16:38 +0000 (19:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Aug 2019 18:09:22 +0000 (11:09 -0700)
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>
t/t3404-rebase-interactive.sh

index 461dd539ffd4803c62d54e22e8921fbefa2c0786..87ee69f78ee7554024d325a8d99d0f16f241abf3 100755 (executable)
@@ -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 &&
        (