83
test_cmp expect actual
84
'
85
86
+sha1_file() {
87
+ echo "$*" | sed "s#..#.git/objects/&/#"
88
+}
89
+remove_object() {
90
+ rm -f $(sha1_file "$*")
91
+}
92
+no_reflog() {
93
+ cp .git/config .git/config.saved &&
94
+ echo "[core] logallrefupdates = false" >>.git/config &&
95
+ test_when_finished "mv -f .git/config.saved .git/config" &&
96
+
97
+ if test -e .git/logs
98
+ then
99
+ mv .git/logs . &&
100
+ test_when_finished "mv logs .git/"
101
+ fi
102
+}
103
+
104
+test_expect_success '--amend option with empty author' '
105
+ git cat-file commit Initial >tmp &&
106
+ sed "s/author [^<]* </author </" tmp >empty-author &&
107
+ no_reflog &&
108
+ sha=$(git hash-object -t commit -w empty-author) &&
109
+ test_when_finished "remove_object $sha" &&
110
+ git checkout $sha &&
111
+ test_when_finished "git checkout Initial" &&
112
+ echo "Empty author test" >>foo &&
113
+ test_tick &&
114
+ ! git commit -a -m "empty author" --amend 2>err &&
115
+ grep "empty ident" err
116
+'
117
+
118
+test_expect_success '--amend option with missing author' '
119
+ git cat-file commit Initial >tmp &&
120
+ sed "s/author [^<]* </author </" tmp >malformed &&
121
+ no_reflog &&
122
+ sha=$(git hash-object -t commit -w malformed) &&
123
+ test_when_finished "remove_object $sha" &&
124
+ git checkout $sha &&
125
+ test_when_finished "git checkout Initial" &&
126
+ echo "Missing author test" >>foo &&
127
+ test_tick &&
128
+ ! git commit -a -m "malformed author" --amend 2>err &&
129
+ grep "empty ident" err
130
+'
131
+
132
test_expect_success '--reset-author makes the commit ours even with --amend option' '
133
git checkout Initial &&
134
echo "Test 6" >>foo &&