@@ -79,6 +79,7 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
7979 } else if (!strcmp (curr , "--no-commit" )) {
8080 opts -> no_commit = 1 ;
8181 } else if (match_str_arg (repo_path , & args , "--git-dir" )) {
82+ continue ;
8283 } else {
8384 print_usage ();
8485 }
@@ -108,22 +109,23 @@ static int resolve_refish(git_annotated_commit **commit, git_repository *repo, c
108109 return err ;
109110}
110111
111- static int resolve_heads (git_repository * repo , merge_options * opts ) {
112+ static int resolve_heads (git_repository * repo , merge_options * opts )
113+ {
112114 git_annotated_commit * * annotated = calloc (opts -> heads_count , sizeof (git_annotated_commit * ));
113115 size_t annotated_count = 0 , i ;
114116 int err = 0 ;
115117
116118 for (i = 0 ; i < opts -> heads_count ; i ++ ) {
117- err = resolve_refish (( git_annotated_commit * * ) & annotated [annotated_count ++ ], repo , opts -> heads [i ]);
119+ err = resolve_refish (& annotated [annotated_count ++ ], repo , opts -> heads [i ]);
118120 if (err != 0 ) {
119- fprintf (stderr , "failed to resolve refish %s (%d) \n" , opts -> heads [i ], err );
121+ fprintf (stderr , "failed to resolve refish %s: %s \n" , opts -> heads [i ], giterr_last () -> message );
120122 annotated_count -- ;
121123 continue ;
122124 }
123125 }
124126
125- if (annotated_count <= 0 ) {
126- fprintf (stderr , "unable to parse any refish\n" );
127+ if (annotated_count != opts -> heads_count ) {
128+ fprintf (stderr , "unable to parse some refish\n" );
127129 free (annotated );
128130 return -1 ;
129131 }
@@ -155,8 +157,8 @@ static int perform_fastforward(git_repository *repo, const git_oid *target_oid,
155157 /* Grab the reference HEAD should be pointing to */
156158 symbolic_ref = git_reference_symbolic_target (head_ref );
157159
158- /* Force-create that reference on the target OID */
159- err = git_reference_create (& target_ref , repo , symbolic_ref , target_oid , 1 , NULL );
160+ /* Create our master reference on the target OID */
161+ err = git_reference_create (& target_ref , repo , symbolic_ref , target_oid , 0 , NULL );
160162 if (err != 0 ) {
161163 fprintf (stderr , "failed to create master reference\n" );
162164 return -1 ;
@@ -179,8 +181,8 @@ static int perform_fastforward(git_repository *repo, const git_oid *target_oid,
179181 return -1 ;
180182 }
181183
182- /* Force-checkout the result so the workdir is in the expected state */
183- ff_checkout_options .checkout_strategy = GIT_CHECKOUT_FORCE ;
184+ /* Checkout the result so the workdir is in the expected state */
185+ ff_checkout_options .checkout_strategy = GIT_CHECKOUT_SAFE ;
184186 err = git_checkout_tree (repo , target , & ff_checkout_options );
185187 if (err != 0 ) {
186188 fprintf (stderr , "failed to checkout HEAD reference\n" );
@@ -209,7 +211,7 @@ static int analyze_merge(git_repository *repo, merge_options *opts)
209211 git_merge_preference_t preference ;
210212 int err = 0 ;
211213
212- merge_opts .flags = 0 ; // GIT_MERGE_FIND_RENAMES;
214+ merge_opts .flags = 0 ;
213215 merge_opts .file_flags = GIT_MERGE_FILE_STYLE_DIFF3 ;
214216
215217 checkout_opts .checkout_strategy = GIT_CHECKOUT_FORCE |GIT_CHECKOUT_ALLOW_CONFLICTS ;
0 commit comments