commit/reset: try to clean up sequencer state
[gitweb.git] / branch.c
index 6a35dd31f2a9c9171a866c66f65cbb30e2e511a8..643694542a51634e0bc5cbef92226913d16ccbe7 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -5,6 +5,7 @@
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
+#include "sequencer.h"
 #include "commit.h"
 #include "worktree.h"
 
@@ -25,9 +26,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
                        tracking->remote = remote->name;
                } else {
                        free(tracking->spec.src);
-                       if (tracking->src) {
-                               FREE_AND_NULL(tracking->src);
-                       }
+                       FREE_AND_NULL(tracking->src);
                }
                tracking->spec.src = NULL;
        }
@@ -244,7 +243,8 @@ N_("\n"
 "will track its remote counterpart, you may want to use\n"
 "\"git push -u\" to set the upstream config as you push.");
 
-void create_branch(const char *name, const char *start_name,
+void create_branch(struct repository *r,
+                  const char *name, const char *start_name,
                   int force, int clobber_head_ok, int reflog,
                   int quiet, enum branch_track track)
 {
@@ -302,7 +302,7 @@ void create_branch(const char *name, const char *start_name,
                break;
        }
 
-       if ((commit = lookup_commit_reference(&oid)) == NULL)
+       if ((commit = lookup_commit_reference(r, &oid)) == NULL)
                die(_("Not a valid branch point: '%s'."), start_name);
        oidcpy(&oid, &commit->object.oid);
 
@@ -338,15 +338,14 @@ void create_branch(const char *name, const char *start_name,
        free(real_ref);
 }
 
-void remove_branch_state(void)
+void remove_branch_state(struct repository *r)
 {
-       unlink(git_path_cherry_pick_head(the_repository));
-       unlink(git_path_revert_head(the_repository));
-       unlink(git_path_merge_head(the_repository));
-       unlink(git_path_merge_rr(the_repository));
-       unlink(git_path_merge_msg(the_repository));
-       unlink(git_path_merge_mode(the_repository));
-       unlink(git_path_squash_msg(the_repository));
+       sequencer_post_commit_cleanup(r);
+       unlink(git_path_merge_head(r));
+       unlink(git_path_merge_rr(r));
+       unlink(git_path_merge_msg(r));
+       unlink(git_path_merge_mode(r));
+       unlink(git_path_squash_msg(r));
 }
 
 void die_if_checked_out(const char *branch, int ignore_current_worktree)