3 # Copyright (c) 2006 Shawn Pearce
6 test_description
='Test git-update-ref and basic ref logging'
9 Z
=0000000000000000000000000000000000000000
10 A
=1111111111111111111111111111111111111111
11 B
=2222222222222222222222222222222222222222
16 'git-update-ref $m $A &&
17 test $A = $(cat .git/$m)'
20 'git-update-ref $m $B $A &&
21 test $B = $(cat .git/$m)'
25 "create $m (by HEAD)" \
26 'git-update-ref HEAD $A &&
27 test $A = $(cat .git/$m)'
29 "create $m (by HEAD)" \
30 'git-update-ref HEAD $B $A &&
31 test $B = $(cat .git/$m)'
35 '(not) create HEAD with old sha1' \
36 'git-update-ref HEAD $A $B'
38 "(not) prior created .git/$m" \
44 'git-update-ref HEAD $A'
46 '(not) change HEAD with wrong SHA1' \
47 'git-update-ref HEAD $B $Z'
49 "(not) changed .git/$m" \
50 'test $B = $(cat .git/$m)'
53 mkdir
-p .git
/logs
/refs
/heads
54 touch .git
/logs
/refs
/heads
/master
56 "create $m (logged by touch)" \
57 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
58 git-update-ref HEAD $A -m "Initial Creation" &&
59 test $A = $(cat .git/$m)'
61 "update $m (logged by touch)" \
62 'GIT_COMMITTER_DATE="2005-05-26 23:31" \
63 git-update-ref HEAD $B $A -m "Switch" &&
64 test $B = $(cat .git/$m)'
66 "set $m (logged by touch)" \
67 'GIT_COMMITTER_DATE="2005-05-26 23:41" \
68 git-update-ref HEAD $A &&
69 test $A = $(cat .git/$m)'
72 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
73 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
74 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
77 "verifying $m's log" \
78 'diff expect .git/logs/$m'
79 rm -rf .git
/$m .git
/logs expect
82 'enable core.logAllRefUpdates' \
83 'git-repo-config core.logAllRefUpdates true &&
84 test true = $(git-repo-config --bool --get core.logAllRefUpdates)'
87 "create $m (logged by config)" \
88 'GIT_COMMITTER_DATE="2005-05-26 23:32" \
89 git-update-ref HEAD $A -m "Initial Creation" &&
90 test $A = $(cat .git/$m)'
92 "update $m (logged by config)" \
93 'GIT_COMMITTER_DATE="2005-05-26 23:33" \
94 git-update-ref HEAD $B $A -m "Switch" &&
95 test $B = $(cat .git/$m)'
97 "set $m (logged by config)" \
98 'GIT_COMMITTER_DATE="2005-05-26 23:43" \
99 git-update-ref HEAD $A &&
100 test $A = $(cat .git/$m)'
103 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation
104 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
105 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
107 test_expect_success \
108 "verifying $m's log" \
109 'diff expect .git/logs/$m'
110 rm -f .git
/$m .git
/logs
/$m expect