1 #include "clar_libgit2.h"
2 #include "git2/rebase.h"
4 static git_repository
*repo
;
5 static git_signature
*signature
;
7 /* Fixture setup and teardown */
8 void test_rebase_sign__initialize(void)
10 repo
= cl_git_sandbox_init("rebase");
11 cl_git_pass(git_signature_new(&signature
, "Rebaser",
12 "rebaser@rebaser.rb", 1405694510, 0));
15 void test_rebase_sign__cleanup(void)
17 git_signature_free(signature
);
18 cl_git_sandbox_cleanup();
21 static int create_cb_passthrough(
23 const git_signature
*author
,
24 const git_signature
*committer
,
25 const char *message_encoding
,
29 const git_commit
*parents
[],
34 GIT_UNUSED(committer
);
35 GIT_UNUSED(message_encoding
);
38 GIT_UNUSED(parent_count
);
42 return GIT_PASSTHROUGH
;
45 /* git checkout gravy ; git rebase --merge veal */
46 void test_rebase_sign__passthrough_create_cb(void)
49 git_reference
*branch_ref
, *upstream_ref
;
50 git_annotated_commit
*branch_head
, *upstream_head
;
51 git_rebase_operation
*rebase_operation
;
52 git_oid commit_id
, expected_id
;
53 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
55 const char *expected_commit_raw_header
= "tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
56 parent f87d14a4a236582a0278a916340a793714256864\n\
57 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
58 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n";
60 rebase_opts
.commit_create_cb
= create_cb_passthrough
;
62 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
63 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
65 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
66 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
68 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
70 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
71 cl_git_pass(git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
73 git_oid_fromstr(&expected_id
, "129183968a65abd6c52da35bff43325001bfc630");
74 cl_assert_equal_oid(&expected_id
, &commit_id
);
76 cl_git_pass(git_commit_lookup(&commit
, repo
, &commit_id
));
77 cl_assert_equal_s(expected_commit_raw_header
, git_commit_raw_header(commit
));
79 cl_git_fail_with(GIT_ITEROVER
, git_rebase_next(&rebase_operation
, rebase
));
81 git_reference_free(branch_ref
);
82 git_reference_free(upstream_ref
);
83 git_annotated_commit_free(branch_head
);
84 git_annotated_commit_free(upstream_head
);
85 git_commit_free(commit
);
86 git_rebase_free(rebase
);
89 static int create_cb_signed_gpg(
91 const git_signature
*author
,
92 const git_signature
*committer
,
93 const char *message_encoding
,
97 const git_commit
*parents
[],
100 git_buf commit_content
= GIT_BUF_INIT
;
101 const char *gpg_signature
= "-----BEGIN PGP SIGNATURE-----\n\
103 iQIzBAEBCgAdFiEEgVlDEfSlmKn0fvGgK++h5T2/ctIFAlwZcrAACgkQK++h5T2/\n\
104 ctIPVhAA42RyZhMdKl5Bm0KtQco2scsukIg2y7tjSwhti91zDu3HQgpusjjo0fQx\n\
105 ZzB+OrmlvQ9CDcGpZ0THIzXD8GRJoDMPqdrvZVrBWkGcHvw7/YPA8skzsjkauJ8W\n\
106 7lzF5LCuHSS6OUmPT/+5hEHPin5PB3zhfszyC+Q7aujnIuPJMrKiMnUa+w1HWifM\n\
107 km49OOygQ9S6NQoVuEQede22+c76DlDL7yFghGoo1f0sKCE/9LW6SEnwI/bWv9eo\n\
108 nom5vOPrvQeJiYCQk+2DyWo8RdSxINtY+G9bPE4RXm+6ZgcXECPm9TYDIWpL36fC\n\
109 jvtGLs98woWFElOziBMp5Tb630GMcSI+q5ivHfJ3WS5NKLYLHBNK4iSFN0/dgAnB\n\
110 dj6GcKXKWnIBWn6ZM4o40pcM5KSRUUCLtA0ZmjJH4c4zx3X5fUxd+enwkf3e9VZO\n\
111 fNKC/+xfq6NfoPUPK9+UnchHpJaJw7RG5tZS+sWCz2xpQ1y3/o49xImNyM3wnpvB\n\
112 cRAZabqIHpZa9/DIUkELOtCzln6niqkjRgg3M/YCCNznwV+0RNgz87VtyTPerdef\n\
113 xrqn0+ROMF6ebVqIs6PPtuPkxnAJu7TMKXVB5rFnAewS24e6cIGFzeIA7810py3l\n\
114 cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
116 -----END PGP SIGNATURE-----";
118 git_repository
*repo
= (git_repository
*)payload
;
121 if ((error
= git_commit_create_buffer(&commit_content
,
122 repo
, author
, committer
, message_encoding
, message
,
123 tree
, parent_count
, parents
)) < 0)
126 error
= git_commit_create_with_signature(out
, repo
,
132 git_buf_dispose(&commit_content
);
136 /* git checkout gravy ; git rebase --merge veal */
137 void test_rebase_sign__create_gpg_signed(void)
140 git_reference
*branch_ref
, *upstream_ref
;
141 git_annotated_commit
*branch_head
, *upstream_head
;
142 git_rebase_operation
*rebase_operation
;
143 git_oid commit_id
, expected_id
;
144 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
146 const char *expected_commit_raw_header
= "tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
147 parent f87d14a4a236582a0278a916340a793714256864\n\
148 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
149 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
150 gpgsig -----BEGIN PGP SIGNATURE-----\n\
152 iQIzBAEBCgAdFiEEgVlDEfSlmKn0fvGgK++h5T2/ctIFAlwZcrAACgkQK++h5T2/\n\
153 ctIPVhAA42RyZhMdKl5Bm0KtQco2scsukIg2y7tjSwhti91zDu3HQgpusjjo0fQx\n\
154 ZzB+OrmlvQ9CDcGpZ0THIzXD8GRJoDMPqdrvZVrBWkGcHvw7/YPA8skzsjkauJ8W\n\
155 7lzF5LCuHSS6OUmPT/+5hEHPin5PB3zhfszyC+Q7aujnIuPJMrKiMnUa+w1HWifM\n\
156 km49OOygQ9S6NQoVuEQede22+c76DlDL7yFghGoo1f0sKCE/9LW6SEnwI/bWv9eo\n\
157 nom5vOPrvQeJiYCQk+2DyWo8RdSxINtY+G9bPE4RXm+6ZgcXECPm9TYDIWpL36fC\n\
158 jvtGLs98woWFElOziBMp5Tb630GMcSI+q5ivHfJ3WS5NKLYLHBNK4iSFN0/dgAnB\n\
159 dj6GcKXKWnIBWn6ZM4o40pcM5KSRUUCLtA0ZmjJH4c4zx3X5fUxd+enwkf3e9VZO\n\
160 fNKC/+xfq6NfoPUPK9+UnchHpJaJw7RG5tZS+sWCz2xpQ1y3/o49xImNyM3wnpvB\n\
161 cRAZabqIHpZa9/DIUkELOtCzln6niqkjRgg3M/YCCNznwV+0RNgz87VtyTPerdef\n\
162 xrqn0+ROMF6ebVqIs6PPtuPkxnAJu7TMKXVB5rFnAewS24e6cIGFzeIA7810py3l\n\
163 cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
165 -----END PGP SIGNATURE-----\n";
167 rebase_opts
.commit_create_cb
= create_cb_signed_gpg
;
168 rebase_opts
.payload
= repo
;
170 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
171 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
173 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
174 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
176 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
178 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
179 cl_git_pass(git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
181 git_oid_fromstr(&expected_id
, "bf78348e45c8286f52b760f1db15cb6da030f2ef");
182 cl_assert_equal_oid(&expected_id
, &commit_id
);
184 cl_git_pass(git_commit_lookup(&commit
, repo
, &commit_id
));
185 cl_assert_equal_s(expected_commit_raw_header
, git_commit_raw_header(commit
));
187 cl_git_fail_with(GIT_ITEROVER
, git_rebase_next(&rebase_operation
, rebase
));
189 git_reference_free(branch_ref
);
190 git_reference_free(upstream_ref
);
191 git_annotated_commit_free(branch_head
);
192 git_annotated_commit_free(upstream_head
);
193 git_commit_free(commit
);
194 git_rebase_free(rebase
);
197 static int create_cb_error(
199 const git_signature
*author
,
200 const git_signature
*committer
,
201 const char *message_encoding
,
203 const git_tree
*tree
,
205 const git_commit
*parents
[],
210 GIT_UNUSED(committer
);
211 GIT_UNUSED(message_encoding
);
214 GIT_UNUSED(parent_count
);
221 /* git checkout gravy ; git rebase --merge veal */
222 void test_rebase_sign__create_propagates_error(void)
225 git_reference
*branch_ref
, *upstream_ref
;
226 git_annotated_commit
*branch_head
, *upstream_head
;
228 git_rebase_operation
*rebase_operation
;
229 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
231 rebase_opts
.commit_create_cb
= create_cb_error
;
233 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
234 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
236 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
237 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
239 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
241 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
242 cl_git_fail_with(GIT_EUSER
, git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
244 git_reference_free(branch_ref
);
245 git_reference_free(upstream_ref
);
246 git_annotated_commit_free(branch_head
);
247 git_annotated_commit_free(upstream_head
);
248 git_rebase_free(rebase
);
251 #ifndef GIT_DEPRECATE_HARD
252 static const char *expected_commit_content
= "\
253 tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
254 parent f87d14a4a236582a0278a916340a793714256864\n\
255 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
256 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
258 Modification 3 to gravy\n";
260 int signing_cb_passthrough(
262 git_buf
*signature_field
,
263 const char *commit_content
,
266 cl_assert_equal_i(0, signature
->size
);
267 cl_assert_equal_i(0, signature_field
->size
);
268 cl_assert_equal_s(expected_commit_content
, commit_content
);
269 cl_assert_equal_p(NULL
, payload
);
270 return GIT_PASSTHROUGH
;
272 #endif /* !GIT_DEPRECATE_HARD */
274 /* git checkout gravy ; git rebase --merge veal */
275 void test_rebase_sign__passthrough_signing_cb(void)
277 #ifndef GIT_DEPRECATE_HARD
279 git_reference
*branch_ref
, *upstream_ref
;
280 git_annotated_commit
*branch_head
, *upstream_head
;
281 git_rebase_operation
*rebase_operation
;
282 git_oid commit_id
, expected_id
;
283 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
285 const char *expected_commit_raw_header
= "tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
286 parent f87d14a4a236582a0278a916340a793714256864\n\
287 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
288 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n";
290 rebase_opts
.signing_cb
= signing_cb_passthrough
;
292 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
293 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
295 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
296 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
298 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
300 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
301 cl_git_pass(git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
303 git_oid_fromstr(&expected_id
, "129183968a65abd6c52da35bff43325001bfc630");
304 cl_assert_equal_oid(&expected_id
, &commit_id
);
306 cl_git_pass(git_commit_lookup(&commit
, repo
, &commit_id
));
307 cl_assert_equal_s(expected_commit_raw_header
, git_commit_raw_header(commit
));
309 cl_git_fail_with(GIT_ITEROVER
, git_rebase_next(&rebase_operation
, rebase
));
311 git_reference_free(branch_ref
);
312 git_reference_free(upstream_ref
);
313 git_annotated_commit_free(branch_head
);
314 git_annotated_commit_free(upstream_head
);
315 git_commit_free(commit
);
316 git_rebase_free(rebase
);
317 #endif /* !GIT_DEPRECATE_HARD */
320 #ifndef GIT_DEPRECATE_HARD
323 git_buf
*signature_field
,
324 const char *commit_content
,
327 const char *gpg_signature
= "\
328 -----BEGIN PGP SIGNATURE-----\n\
330 iQIzBAEBCgAdFiEEgVlDEfSlmKn0fvGgK++h5T2/ctIFAlwZcrAACgkQK++h5T2/\n\
331 ctIPVhAA42RyZhMdKl5Bm0KtQco2scsukIg2y7tjSwhti91zDu3HQgpusjjo0fQx\n\
332 ZzB+OrmlvQ9CDcGpZ0THIzXD8GRJoDMPqdrvZVrBWkGcHvw7/YPA8skzsjkauJ8W\n\
333 7lzF5LCuHSS6OUmPT/+5hEHPin5PB3zhfszyC+Q7aujnIuPJMrKiMnUa+w1HWifM\n\
334 km49OOygQ9S6NQoVuEQede22+c76DlDL7yFghGoo1f0sKCE/9LW6SEnwI/bWv9eo\n\
335 nom5vOPrvQeJiYCQk+2DyWo8RdSxINtY+G9bPE4RXm+6ZgcXECPm9TYDIWpL36fC\n\
336 jvtGLs98woWFElOziBMp5Tb630GMcSI+q5ivHfJ3WS5NKLYLHBNK4iSFN0/dgAnB\n\
337 dj6GcKXKWnIBWn6ZM4o40pcM5KSRUUCLtA0ZmjJH4c4zx3X5fUxd+enwkf3e9VZO\n\
338 fNKC/+xfq6NfoPUPK9+UnchHpJaJw7RG5tZS+sWCz2xpQ1y3/o49xImNyM3wnpvB\n\
339 cRAZabqIHpZa9/DIUkELOtCzln6niqkjRgg3M/YCCNznwV+0RNgz87VtyTPerdef\n\
340 xrqn0+ROMF6ebVqIs6PPtuPkxnAJu7TMKXVB5rFnAewS24e6cIGFzeIA7810py3l\n\
341 cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
343 -----END PGP SIGNATURE-----";
345 cl_assert_equal_i(0, signature
->size
);
346 cl_assert_equal_i(0, signature_field
->size
);
347 cl_assert_equal_s(expected_commit_content
, commit_content
);
348 cl_assert_equal_p(NULL
, payload
);
350 cl_git_pass(git_buf_set(signature
, gpg_signature
, strlen(gpg_signature
) + 1));
353 #endif /* !GIT_DEPRECATE_HARD */
355 /* git checkout gravy ; git rebase --merge veal */
356 void test_rebase_sign__gpg_with_no_field(void)
358 #ifndef GIT_DEPRECATE_HARD
360 git_reference
*branch_ref
, *upstream_ref
;
361 git_annotated_commit
*branch_head
, *upstream_head
;
362 git_rebase_operation
*rebase_operation
;
363 git_oid commit_id
, expected_id
;
364 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
366 const char *expected_commit_raw_header
= "\
367 tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
368 parent f87d14a4a236582a0278a916340a793714256864\n\
369 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
370 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
371 gpgsig -----BEGIN PGP SIGNATURE-----\n\
373 iQIzBAEBCgAdFiEEgVlDEfSlmKn0fvGgK++h5T2/ctIFAlwZcrAACgkQK++h5T2/\n\
374 ctIPVhAA42RyZhMdKl5Bm0KtQco2scsukIg2y7tjSwhti91zDu3HQgpusjjo0fQx\n\
375 ZzB+OrmlvQ9CDcGpZ0THIzXD8GRJoDMPqdrvZVrBWkGcHvw7/YPA8skzsjkauJ8W\n\
376 7lzF5LCuHSS6OUmPT/+5hEHPin5PB3zhfszyC+Q7aujnIuPJMrKiMnUa+w1HWifM\n\
377 km49OOygQ9S6NQoVuEQede22+c76DlDL7yFghGoo1f0sKCE/9LW6SEnwI/bWv9eo\n\
378 nom5vOPrvQeJiYCQk+2DyWo8RdSxINtY+G9bPE4RXm+6ZgcXECPm9TYDIWpL36fC\n\
379 jvtGLs98woWFElOziBMp5Tb630GMcSI+q5ivHfJ3WS5NKLYLHBNK4iSFN0/dgAnB\n\
380 dj6GcKXKWnIBWn6ZM4o40pcM5KSRUUCLtA0ZmjJH4c4zx3X5fUxd+enwkf3e9VZO\n\
381 fNKC/+xfq6NfoPUPK9+UnchHpJaJw7RG5tZS+sWCz2xpQ1y3/o49xImNyM3wnpvB\n\
382 cRAZabqIHpZa9/DIUkELOtCzln6niqkjRgg3M/YCCNznwV+0RNgz87VtyTPerdef\n\
383 xrqn0+ROMF6ebVqIs6PPtuPkxnAJu7TMKXVB5rFnAewS24e6cIGFzeIA7810py3l\n\
384 cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
386 -----END PGP SIGNATURE-----\n";
388 rebase_opts
.signing_cb
= signing_cb_gpg
;
390 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
391 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
393 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
394 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
396 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
398 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
399 cl_git_pass(git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
401 git_oid_fromstr(&expected_id
, "bf78348e45c8286f52b760f1db15cb6da030f2ef");
402 cl_assert_equal_oid(&expected_id
, &commit_id
);
404 cl_git_pass(git_commit_lookup(&commit
, repo
, &commit_id
));
405 cl_assert_equal_s(expected_commit_raw_header
, git_commit_raw_header(commit
));
407 cl_git_fail_with(GIT_ITEROVER
, git_rebase_next(&rebase_operation
, rebase
));
409 git_reference_free(branch_ref
);
410 git_reference_free(upstream_ref
);
411 git_annotated_commit_free(branch_head
);
412 git_annotated_commit_free(upstream_head
);
413 git_commit_free(commit
);
414 git_rebase_free(rebase
);
415 #endif /* !GIT_DEPRECATE_HARD */
419 #ifndef GIT_DEPRECATE_HARD
420 int signing_cb_magic_field(
422 git_buf
*signature_field
,
423 const char *commit_content
,
426 const char *signature_content
= "magic word: pretty please";
427 const char *signature_field_content
= "magicsig";
429 cl_assert_equal_p(NULL
, signature
->ptr
);
430 cl_assert_equal_i(0, signature
->size
);
431 cl_assert_equal_p(NULL
, signature_field
->ptr
);
432 cl_assert_equal_i(0, signature_field
->size
);
433 cl_assert_equal_s(expected_commit_content
, commit_content
);
434 cl_assert_equal_p(NULL
, payload
);
436 cl_git_pass(git_buf_set(signature
, signature_content
,
437 strlen(signature_content
) + 1));
438 cl_git_pass(git_buf_set(signature_field
, signature_field_content
,
439 strlen(signature_field_content
) + 1));
443 #endif /* !GIT_DEPRECATE_HARD */
445 /* git checkout gravy ; git rebase --merge veal */
446 void test_rebase_sign__custom_signature_field(void)
448 #ifndef GIT_DEPRECATE_HARD
450 git_reference
*branch_ref
, *upstream_ref
;
451 git_annotated_commit
*branch_head
, *upstream_head
;
452 git_rebase_operation
*rebase_operation
;
453 git_oid commit_id
, expected_id
;
454 git_rebase_options rebase_opts
= GIT_REBASE_OPTIONS_INIT
;
456 const char *expected_commit_raw_header
= "\
457 tree cd99b26250099fc38d30bfaed7797a7275ed3366\n\
458 parent f87d14a4a236582a0278a916340a793714256864\n\
459 author Edward Thomson <ethomson@edwardthomson.com> 1405625055 -0400\n\
460 committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n\
461 magicsig magic word: pretty please\n";
463 rebase_opts
.signing_cb
= signing_cb_magic_field
;
465 cl_git_pass(git_reference_lookup(&branch_ref
, repo
, "refs/heads/gravy"));
466 cl_git_pass(git_reference_lookup(&upstream_ref
, repo
, "refs/heads/veal"));
468 cl_git_pass(git_annotated_commit_from_ref(&branch_head
, repo
, branch_ref
));
469 cl_git_pass(git_annotated_commit_from_ref(&upstream_head
, repo
, upstream_ref
));
471 cl_git_pass(git_rebase_init(&rebase
, repo
, branch_head
, upstream_head
, NULL
, &rebase_opts
));
473 cl_git_pass(git_rebase_next(&rebase_operation
, rebase
));
474 cl_git_pass(git_rebase_commit(&commit_id
, rebase
, NULL
, signature
, NULL
, NULL
));
476 git_oid_fromstr(&expected_id
, "f46a4a8d26ae411b02aa61b7d69576627f4a1e1c");
477 cl_assert_equal_oid(&expected_id
, &commit_id
);
479 cl_git_pass(git_commit_lookup(&commit
, repo
, &commit_id
));
480 cl_assert_equal_s(expected_commit_raw_header
, git_commit_raw_header(commit
));
482 cl_git_fail_with(GIT_ITEROVER
, git_rebase_next(&rebase_operation
, rebase
));
484 git_reference_free(branch_ref
);
485 git_reference_free(upstream_ref
);
486 git_annotated_commit_free(branch_head
);
487 git_annotated_commit_free(upstream_head
);
488 git_commit_free(commit
);
489 git_rebase_free(rebase
);
490 #endif /* !GIT_DEPRECATE_HARD */