20
20
test_expect_success \
22
"git-update-ref $m $A &&
22
"git update-ref $m $A &&
23
23
test $A"' = $(cat .git/'"$m"')'
24
24
test_expect_success \
26
"git-update-ref $m $B $A &&
26
"git update-ref $m $B $A &&
27
27
test $B"' = $(cat .git/'"$m"')'
30
30
test_expect_success \
31
31
"fail to create $n" \
33
git-update-ref $n $A >out 2>err"'
33
git update-ref $n $A >out 2>err"'
35
35
rm -f .git/$n_dir out err
37
37
test_expect_success \
38
38
"create $m (by HEAD)" \
39
"git-update-ref HEAD $A &&
39
"git update-ref HEAD $A &&
40
40
test $A"' = $(cat .git/'"$m"')'
41
41
test_expect_success \
42
42
"create $m (by HEAD)" \
43
"git-update-ref HEAD $B $A &&
43
"git update-ref HEAD $B $A &&
44
44
test $B"' = $(cat .git/'"$m"')'
47
47
test_expect_failure \
48
48
'(not) create HEAD with old sha1' \
49
"git-update-ref HEAD $A $B"
49
"git update-ref HEAD $A $B"
50
50
test_expect_failure \
51
51
"(not) prior created .git/$m" \
55
55
test_expect_success \
57
"git-update-ref HEAD $A"
57
"git update-ref HEAD $A"
58
58
test_expect_failure \
59
59
'(not) change HEAD with wrong SHA1' \
60
"git-update-ref HEAD $B $Z"
60
"git update-ref HEAD $B $Z"
61
61
test_expect_failure \
62
62
"(not) changed .git/$m" \
63
63
"test $B"' = $(cat .git/'"$m"')'
68
68
test_expect_success \
69
69
"create $m (logged by touch)" \
70
70
'GIT_COMMITTER_DATE="2005-05-26 23:30" \
71
git-update-ref HEAD '"$A"' -m "Initial Creation" &&
71
git update-ref HEAD '"$A"' -m "Initial Creation" &&
72
72
test '"$A"' = $(cat .git/'"$m"')'
73
73
test_expect_success \
74
74
"update $m (logged by touch)" \
75
75
'GIT_COMMITTER_DATE="2005-05-26 23:31" \
76
git-update-ref HEAD'" $B $A "'-m "Switch" &&
76
git update-ref HEAD'" $B $A "'-m "Switch" &&
77
77
test '"$B"' = $(cat .git/'"$m"')'
78
78
test_expect_success \
79
79
"set $m (logged by touch)" \
80
80
'GIT_COMMITTER_DATE="2005-05-26 23:41" \
81
git-update-ref HEAD'" $A &&
81
git update-ref HEAD'" $A &&
82
82
test $A"' = $(cat .git/'"$m"')'
94
94
test_expect_success \
95
95
'enable core.logAllRefUpdates' \
96
'git-config core.logAllRefUpdates true &&
97
test true = $(git-config --bool --get core.logAllRefUpdates)'
96
'git config core.logAllRefUpdates true &&
97
test true = $(git config --bool --get core.logAllRefUpdates)'
99
99
test_expect_success \
100
100
"create $m (logged by config)" \
101
101
'GIT_COMMITTER_DATE="2005-05-26 23:32" \
102
git-update-ref HEAD'" $A "'-m "Initial Creation" &&
102
git update-ref HEAD'" $A "'-m "Initial Creation" &&
103
103
test '"$A"' = $(cat .git/'"$m"')'
104
104
test_expect_success \
105
105
"update $m (logged by config)" \
106
106
'GIT_COMMITTER_DATE="2005-05-26 23:33" \
107
git-update-ref HEAD'" $B $A "'-m "Switch" &&
107
git update-ref HEAD'" $B $A "'-m "Switch" &&
108
108
test '"$B"' = $(cat .git/'"$m"')'
109
109
test_expect_success \
110
110
"set $m (logged by config)" \
111
111
'GIT_COMMITTER_DATE="2005-05-26 23:43" \
112
git-update-ref HEAD '"$A &&
112
git update-ref HEAD '"$A &&
113
113
test $A"' = $(cat .git/'"$m"')'
115
115
cat >expect <<EOF
136
136
test_expect_success \
137
137
'Query "master@{May 25 2005}" (before history)' \
139
git-rev-parse --verify "master@{May 25 2005}" >o 2>e &&
139
git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
140
140
test '"$C"' = $(cat o) &&
141
141
test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
142
142
test_expect_success \
143
143
"Query master@{2005-05-25} (before history)" \
145
git-rev-parse --verify master@{2005-05-25} >o 2>e &&
145
git rev-parse --verify master@{2005-05-25} >o 2>e &&
146
146
test '"$C"' = $(cat o) &&
147
147
echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
148
148
test_expect_success \
149
149
'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
151
git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
151
git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
152
152
test '"$C"' = $(cat o) &&
153
153
test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
154
154
test_expect_success \
155
155
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
157
git-rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
157
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
158
158
test '"$A"' = $(cat o) &&
159
159
test "" = "$(cat e)"'
160
160
test_expect_success \
161
161
'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
163
git-rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
163
git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
164
164
test '"$B"' = $(cat o) &&
165
165
test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"'
166
166
test_expect_success \
167
167
'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
169
git-rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
169
git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
170
170
test '"$Z"' = $(cat o) &&
171
171
test "" = "$(cat e)"'
172
172
test_expect_success \
173
173
'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
175
git-rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
175
git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
176
176
test '"$E"' = $(cat o) &&
177
177
test "" = "$(cat e)"'
178
178
test_expect_success \
179
179
'Query "master@{2005-05-28}" (past end of history)' \
181
git-rev-parse --verify "master@{2005-05-28}" >o 2>e &&
181
git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
182
182
test '"$D"' = $(cat o) &&
183
183
test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"'
188
188
test_expect_success \
189
189
'creating initial files' \
192
192
GIT_AUTHOR_DATE="2005-05-26 23:30" \
193
193
GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a &&
194
h_TEST=$(git-rev-parse --verify HEAD)
194
h_TEST=$(git rev-parse --verify HEAD)
195
195
echo The other day this did not work. >M &&
196
196
echo And then Bob told me how to fix it. >>M &&
198
198
GIT_AUTHOR_DATE="2005-05-26 23:41" \
199
199
GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
200
h_OTHER=$(git-rev-parse --verify HEAD) &&
200
h_OTHER=$(git rev-parse --verify HEAD) &&
202
201
GIT_AUTHOR_DATE="2005-05-26 23:44" \
203
202
GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
204
h_FIXED=$(git-rev-parse --verify HEAD) &&
205
echo TEST+FIXED >F &&
203
h_FIXED=$(git rev-parse --verify HEAD) &&
206
204
echo Merged initial commit and a later commit. >M &&
207
205
echo $h_TEST >.git/MERGE_HEAD &&
208
206
GIT_AUTHOR_DATE="2005-05-26 23:45" \
209
207
GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M &&
210
h_MERGED=$(git-rev-parse --verify HEAD)
208
h_MERGED=$(git rev-parse --verify HEAD)
213
211
cat >expect <<EOF
222
220
unset h_TEST h_OTHER h_FIXED h_MERGED
224
222
test_expect_success \
225
'git-cat-file blob master:F (expect OTHER)' \
226
'test OTHER = $(git-cat-file blob master:F)'
227
test_expect_success \
228
'git-cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
229
'test TEST = $(git-cat-file blob "master@{2005-05-26 23:30}:F")'
230
test_expect_success \
231
'git-cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
232
'test OTHER = $(git-cat-file blob "master@{2005-05-26 23:42}:F")'
223
'git cat-file blob master:F (expect OTHER)' \
224
'test OTHER = $(git cat-file blob master:F)'
225
test_expect_success \
226
'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
227
'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'
228
test_expect_success \
229
'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
230
'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'