55#include <fcntl.h>
66
77static git_repository * repo ;
8+ static git_signature * signature ;
89
910// Fixture setup and teardown
1011void test_rebase_inmemory__initialize (void )
1112{
1213 repo = cl_git_sandbox_init ("rebase" );
14+
15+ cl_git_pass (git_signature_new (& signature ,
16+ "Rebaser" , "rebaser@rebaser.rb" , 1405694510 , 0 ));
1317}
1418
1519void test_rebase_inmemory__cleanup (void )
1620{
21+ git_signature_free (signature );
1722 cl_git_sandbox_cleanup ();
1823}
1924
@@ -53,14 +58,10 @@ void test_rebase_inmemory__can_resolve_conflicts(void)
5358 git_rebase_operation * rebase_operation ;
5459 git_status_list * status_list ;
5560 git_oid pick_id , commit_id , expected_commit_id ;
56- git_signature * signature ;
5761 git_index * rebase_index , * repo_index ;
5862 git_index_entry resolution = {{0 }};
5963 git_rebase_options opts = GIT_REBASE_OPTIONS_INIT ;
6064
61- cl_git_pass (git_signature_new (& signature ,
62- "Rebaser" , "rebaser@rebaser.rb" , 1405694510 , 0 ));
63-
6465 opts .inmemory = true;
6566
6667 cl_git_pass (git_reference_lookup (& branch_ref , repo , "refs/heads/asparagus" ));
@@ -104,7 +105,6 @@ void test_rebase_inmemory__can_resolve_conflicts(void)
104105 cl_git_pass (git_oid_fromstr (& expected_commit_id , "db7af47222181e548810da2ab5fec0e9357c5637" ));
105106 cl_assert_equal_oid (& commit_id , & expected_commit_id );
106107
107- git_signature_free (signature );
108108 git_status_list_free (status_list );
109109 git_annotated_commit_free (branch_head );
110110 git_annotated_commit_free (upstream_head );
@@ -114,3 +114,54 @@ void test_rebase_inmemory__can_resolve_conflicts(void)
114114 git_index_free (rebase_index );
115115 git_rebase_free (rebase );
116116}
117+
118+ void test_rebase_inmemory__no_common_ancestor (void )
119+ {
120+ git_rebase * rebase ;
121+ git_reference * branch_ref , * upstream_ref ;
122+ git_annotated_commit * branch_head , * upstream_head ;
123+ git_rebase_operation * rebase_operation ;
124+ git_oid commit_id , expected_final_id ;
125+ git_rebase_options opts = GIT_REBASE_OPTIONS_INIT ;
126+
127+ opts .inmemory = true;
128+
129+ cl_git_pass (git_reference_lookup (& branch_ref , repo , "refs/heads/barley" ));
130+ cl_git_pass (git_reference_lookup (& upstream_ref , repo , "refs/heads/master" ));
131+
132+ cl_git_pass (git_annotated_commit_from_ref (& branch_head , repo , branch_ref ));
133+ cl_git_pass (git_annotated_commit_from_ref (& upstream_head , repo , upstream_ref ));
134+
135+ cl_git_pass (git_rebase_init (& rebase , repo , branch_head , upstream_head , NULL , & opts ));
136+
137+ cl_git_pass (git_rebase_next (& rebase_operation , rebase ));
138+ cl_git_pass (git_rebase_commit (& commit_id , rebase , NULL , signature ,
139+ NULL , NULL ));
140+
141+ cl_git_pass (git_rebase_next (& rebase_operation , rebase ));
142+ cl_git_pass (git_rebase_commit (& commit_id , rebase , NULL , signature ,
143+ NULL , NULL ));
144+
145+ cl_git_pass (git_rebase_next (& rebase_operation , rebase ));
146+ cl_git_pass (git_rebase_commit (& commit_id , rebase , NULL , signature ,
147+ NULL , NULL ));
148+
149+ cl_git_pass (git_rebase_next (& rebase_operation , rebase ));
150+ cl_git_pass (git_rebase_commit (& commit_id , rebase , NULL , signature ,
151+ NULL , NULL ));
152+
153+ cl_git_pass (git_rebase_next (& rebase_operation , rebase ));
154+ cl_git_pass (git_rebase_commit (& commit_id , rebase , NULL , signature ,
155+ NULL , NULL ));
156+
157+ cl_git_pass (git_rebase_finish (rebase , signature ));
158+
159+ git_oid_fromstr (& expected_final_id , "71e7ee8d4fe7d8bf0d107355197e0a953dfdb7f3" );
160+ cl_assert_equal_oid (& expected_final_id , & commit_id );
161+
162+ git_annotated_commit_free (branch_head );
163+ git_annotated_commit_free (upstream_head );
164+ git_reference_free (branch_ref );
165+ git_reference_free (upstream_ref );
166+ git_rebase_free (rebase );
167+ }
0 commit comments