switch: implicit dwim, use --no-guess to disable it
[gitweb.git] / branch.c
index 28b81a7e0256b2923c0fe296d9618d130821cdc4..8dd5bb9f1c38ac5bf94b9cb845b3dba0daceac10 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -337,11 +337,14 @@ void create_branch(struct repository *r,
        free(real_ref);
 }
 
-void remove_branch_state(struct repository *r)
+void remove_branch_state(struct repository *r, int verbose)
 {
-       unlink(git_path_cherry_pick_head(r));
-       unlink(git_path_revert_head(r));
-       unlink(git_path_merge_head(r));
+       if (!unlink(git_path_cherry_pick_head(r)) && verbose)
+               warning(_("cancelling a cherry picking in progress"));
+       if (!unlink(git_path_revert_head(r)) && verbose)
+               warning(_("cancelling a revert in progress"));
+       if (!unlink(git_path_merge_head(r)) && verbose)
+               warning(_("cancelling a merge in progress"));
        unlink(git_path_merge_rr(r));
        unlink(git_path_merge_msg(r));
        unlink(git_path_merge_mode(r));