Skip to content

Commit 736f2ef

Browse files
bk2204gitster
authored andcommitted
t2101: abstract away SHA-1-specific constants
Adjust the test so that it uses variables and command substitution for blobs instead of hard-coded hashes. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7cbae72 commit 736f2ef

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

t/t2101-update-index-reupdate.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ test_description='git update-index --again test.
88

99
. ./test-lib.sh
1010

11-
cat > expected <<\EOF
12-
100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
13-
100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
14-
EOF
1511
test_expect_success 'update-index --add' '
1612
echo hello world >file1 &&
1713
echo goodbye people >file2 &&
1814
git update-index --add file1 file2 &&
1915
git ls-files -s >current &&
16+
cat >expected <<-EOF &&
17+
100644 $(git hash-object file1) 0 file1
18+
100644 $(git hash-object file2) 0 file2
19+
EOF
2020
cmp current expected
2121
'
2222

@@ -34,21 +34,17 @@ test_expect_success 'update-index --again' '
3434
cmp current expected
3535
'
3636

37-
cat > expected <<\EOF
38-
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
39-
EOF
4037
test_expect_success 'update-index --remove --again' '
4138
git update-index --remove --again &&
4239
git ls-files -s >current &&
40+
cat >expected <<-EOF &&
41+
100644 $(git hash-object file2) 0 file2
42+
EOF
4343
cmp current expected
4444
'
4545

4646
test_expect_success 'first commit' 'git commit -m initial'
4747

48-
cat > expected <<\EOF
49-
100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
50-
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
51-
EOF
5248
test_expect_success 'update-index again' '
5349
mkdir -p dir1 &&
5450
echo hello world >dir1/file3 &&
@@ -58,32 +54,37 @@ test_expect_success 'update-index again' '
5854
echo happy >dir1/file3 &&
5955
git update-index --again &&
6056
git ls-files -s >current &&
57+
cat >expected <<-EOF &&
58+
100644 $(git hash-object dir1/file3) 0 dir1/file3
59+
100644 $(git hash-object file2) 0 file2
60+
EOF
6161
cmp current expected
6262
'
6363

64-
cat > expected <<\EOF
65-
100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
66-
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
67-
EOF
64+
file2=$(git hash-object file2)
6865
test_expect_success 'update-index --update from subdir' '
6966
echo not so happy >file2 &&
7067
(cd dir1 &&
7168
cat ../file2 >file3 &&
7269
git update-index --again
7370
) &&
7471
git ls-files -s >current &&
75-
cmp current expected
72+
cat >expected <<-EOF &&
73+
100644 $(git hash-object dir1/file3) 0 dir1/file3
74+
100644 $file2 0 file2
75+
EOF
76+
test_cmp current expected
7677
'
7778

78-
cat > expected <<\EOF
79-
100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
80-
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
81-
EOF
8279
test_expect_success 'update-index --update with pathspec' '
8380
echo very happy >file2 &&
8481
cat file2 >dir1/file3 &&
8582
git update-index --again dir1/ &&
8683
git ls-files -s >current &&
84+
cat >expected <<-EOF &&
85+
100644 $(git hash-object dir1/file3) 0 dir1/file3
86+
100644 $file2 0 file2
87+
EOF
8788
cmp current expected
8889
'
8990

0 commit comments

Comments
 (0)