@@ -25,9 +25,14 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
2525\n\
2626Modification 3 to gravy\n" ;
2727
28- int signature_cb_passthrough (char * * signature , const char * commit_content , void * payload )
28+ int signature_cb_passthrough (
29+ git_buf * signature ,
30+ git_buf * signature_field ,
31+ const char * commit_content ,
32+ void * payload )
2933{
30- cl_assert_equal_p (NULL , * signature );
34+ cl_assert_equal_b (false, git_buf_is_allocated (signature ));
35+ cl_assert_equal_b (false, git_buf_is_allocated (signature_field ));
3136 cl_assert_equal_s (expected_commit_content , commit_content );
3237 cl_assert_equal_p (NULL , payload );
3338 return GIT_PASSTHROUGH ;
@@ -79,7 +84,11 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n";
7984 git_rebase_free (rebase );
8085}
8186
82- int signature_cb_gpg (char * * signature , const char * commit_content , void * payload )
87+ int signature_cb_gpg (
88+ git_buf * signature ,
89+ git_buf * signature_field ,
90+ const char * commit_content ,
91+ void * payload )
8392{
8493 const char * gpg_signature = "-----BEGIN PGP SIGNATURE-----\n\
8594\n\
@@ -98,22 +107,17 @@ cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
98107=KbsY\n\
99108-----END PGP SIGNATURE-----" ;
100109
110+ cl_assert_equal_b (false, git_buf_is_allocated (signature ));
111+ cl_assert_equal_b (false, git_buf_is_allocated (signature_field ));
101112 cl_assert_equal_s (expected_commit_content , commit_content );
102113 cl_assert_equal_p (NULL , payload );
103114
104- * signature = strdup (gpg_signature );
115+ cl_git_pass ( git_buf_set ( signature , gpg_signature , strlen (gpg_signature ) + 1 ) );
105116 return GIT_OK ;
106117}
107118
108- int signature_field_cb_passthrough (char * * signature_field , void * payload )
109- {
110- cl_assert_equal_p (NULL , * signature_field );
111- cl_assert_equal_p (NULL , payload );
112- return GIT_PASSTHROUGH ;
113- }
114-
115119/* git checkout gravy ; git rebase --merge veal */
116- void test_gpg_signature ( bool use_passthrough )
120+ void test_rebase_sign__gpg_with_no_field ( void )
117121{
118122 git_rebase * rebase ;
119123 git_reference * branch_ref , * upstream_ref ;
@@ -145,8 +149,6 @@ gpgsig -----BEGIN PGP SIGNATURE-----\n\
145149 -----END PGP SIGNATURE-----\n" ;
146150
147151 rebase_opts .signature_cb = signature_cb_gpg ;
148- if (use_passthrough )
149- rebase_opts .signature_field_cb = signature_field_cb_passthrough ;
150152
151153 cl_git_pass (git_reference_lookup (& branch_ref , repo , "refs/heads/gravy" ));
152154 cl_git_pass (git_reference_lookup (& upstream_ref , repo , "refs/heads/veal" ));
@@ -176,30 +178,26 @@ gpgsig -----BEGIN PGP SIGNATURE-----\n\
176178 git_rebase_free (rebase );
177179}
178180
179- /* git checkout gravy ; git rebase --merge veal */
180- void test_rebase_sign__gpg_with_no_field_cb (void )
181- {
182- test_gpg_signature (false);
183- }
184181
185- /* git checkout gravy ; git rebase --merge veal */
186- void test_rebase_sign__gpg_with_passthrough_field_cb (void )
182+ int signature_cb_magic_field (
183+ git_buf * signature ,
184+ git_buf * signature_field ,
185+ const char * commit_content ,
186+ void * payload )
187187{
188- test_gpg_signature (true) ;
189- }
188+ const char * signature_content = "magic word: pretty please" ;
189+ const char * signature_field_content = "magicsig" ;
190190
191- int signature_cb_magic_field ( char * * signature , const char * commit_content , void * payload )
192- {
191+ cl_assert_equal_b (false, git_buf_is_allocated ( signature ));
192+ cl_assert_equal_b (false, git_buf_is_allocated ( signature_field ));
193193 cl_assert_equal_s (expected_commit_content , commit_content );
194194 cl_assert_equal_p (NULL , payload );
195- * signature = strdup ("magic word: pretty please" );
196- return GIT_OK ;
197- }
198195
199- int signature_field_cb_magic_field (char * * signature_field , void * payload )
200- {
201- cl_assert_equal_p (NULL , payload );
202- * signature_field = strdup ("magicsig" );
196+ cl_git_pass (git_buf_set (signature , signature_content ,
197+ strlen (signature_content ) + 1 ));
198+ cl_git_pass (git_buf_set (signature_field , signature_field_content ,
199+ strlen (signature_field_content ) + 1 ));
200+
203201 return GIT_OK ;
204202}
205203
@@ -221,7 +219,6 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
221219magicsig magic word: pretty please\n" ;
222220
223221 rebase_opts .signature_cb = signature_cb_magic_field ;
224- rebase_opts .signature_field_cb = signature_field_cb_magic_field ;
225222
226223 cl_git_pass (git_reference_lookup (& branch_ref , repo , "refs/heads/gravy" ));
227224 cl_git_pass (git_reference_lookup (& upstream_ref , repo , "refs/heads/veal" ));
0 commit comments