@@ -215,27 +215,37 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
215215 const git_oid * oid ;
216216
217217 if ((error = git_reference_resolve (& r , ref )) < GIT_SUCCESS )
218- return git__rethrow (error , "Failed to write reflog. Cannot resolve reference `%s`" , ref -> name );
218+ return git__rethrow (error ,
219+ "Failed to write reflog. Cannot resolve reference `%s`" , ref -> name );
219220
220221 oid = git_reference_oid (r );
221222 if (oid == NULL ) {
222223 git_reference_free (r );
223- return git__throw (GIT_ERROR , "Failed to write reflog. Cannot resolve reference `%s`" , r -> name );
224+ return git__throw (GIT_ERROR ,
225+ "Failed to write reflog. Cannot resolve reference `%s`" , r -> name );
224226 }
225227
226- git_reference_free (r );
227-
228228 git_oid_to_string (new , GIT_OID_HEXSZ + 1 , oid );
229229
230- git_path_join_n (log_path , 3 , ref -> owner -> path_repository , GIT_REFLOG_DIR , ref -> name );
230+ git_path_join_n (log_path , 3 ,
231+ ref -> owner -> path_repository , GIT_REFLOG_DIR , ref -> name );
232+
233+ git_reference_free (r );
231234
232235 if (git_futils_exists (log_path )) {
233- if ((error = git_futils_mkpath2file (log_path , GIT_REFLOG_DIR_MODE )) < GIT_SUCCESS )
234- return git__rethrow (error , "Failed to write reflog. Cannot create reflog directory" );
236+ error = git_futils_mkpath2file (log_path , GIT_REFLOG_DIR_MODE );
237+ if (error < GIT_SUCCESS )
238+ return git__rethrow (error ,
239+ "Failed to write reflog. Cannot create reflog directory" );
240+
235241 } else if (git_futils_isfile (log_path )) {
236- return git__throw (GIT_ERROR , "Failed to write reflog. `%s` is directory" , log_path );
237- } else if (oid_old == NULL )
238- return git__throw (GIT_ERROR , "Failed to write reflog. Old OID cannot be NULL for existing reference" );
242+ return git__throw (GIT_ERROR ,
243+ "Failed to write reflog. `%s` is directory" , log_path );
244+
245+ } else if (oid_old == NULL ) {
246+ return git__throw (GIT_ERROR ,
247+ "Failed to write reflog. Old OID cannot be NULL for existing reference" );
248+ }
239249
240250 if (oid_old )
241251 git_oid_to_string (old , GIT_OID_HEXSZ + 1 , oid_old );
0 commit comments