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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Mar 25, 2018 at 19:20 UTC
736f2efcfb841b11e25007f6baebd4a4c64bcaa5
1 file changed
+21
-20
t/t2101-update-index-reupdate.sh
+21
-20
@@ -8,15 +8,15 @@ test_description='git update-index --again test.
8
9
. ./test-lib.sh
10
11
-cat > expected <<\EOF
12
-100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
13
-100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
14
-EOF
11
test_expect_success 'update-index --add' '
12
echo hello world >file1 &&
13
echo goodbye people >file2 &&
14
git update-index --add file1 file2 &&
15
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
20
cmp current expected
21
'
22
@@ -34,21 +34,17 @@ test_expect_success 'update-index --again' '
34
cmp current expected
35
'
36
37
-cat > expected <<\EOF
38
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
39
-EOF
37
test_expect_success 'update-index --remove --again' '
38
git update-index --remove --again &&
39
git ls-files -s >current &&
40
+ cat >expected <<-EOF &&
41
+ 100644 $(git hash-object file2) 0 file2
42
+ EOF
43
cmp current expected
44
'
45
46
test_expect_success 'first commit' 'git commit -m initial'
47
48
-cat > expected <<\EOF
49
-100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
50
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
51
-EOF
48
test_expect_success 'update-index again' '
49
mkdir -p dir1 &&
50
echo hello world >dir1/file3 &&
@@ -58,13 +54,14 @@ test_expect_success 'update-index again' '
54
echo happy >dir1/file3 &&
55
git update-index --again &&
56
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
61
cmp current expected
62
'
63
64
-cat > expected <<\EOF
65
-100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
66
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
67
-EOF
64
+file2=$(git hash-object file2)
65
test_expect_success 'update-index --update from subdir' '
66
echo not so happy >file2 &&
67
(cd dir1 &&
@@ -72,18 +69,22 @@ test_expect_success 'update-index --update from subdir' '
69
git update-index --again
70
) &&
71
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
77
'
78
78
-cat > expected <<\EOF
79
-100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
80
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
81
-EOF
79
test_expect_success 'update-index --update with pathspec' '
80
echo very happy >file2 &&
81
cat file2 >dir1/file3 &&
82
git update-index --again dir1/ &&
83
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
88
cmp current expected
89
'
90