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));
* Remove information about the state of working on the current
* branch. (E.g., MERGE_HEAD)
*/
-void remove_branch_state(struct repository *r);
+void remove_branch_state(struct repository *r, int verbose);
/*
* Configure local branch "local" as downstream to branch "remote"
if (merge_tree(remote_tree))
return -1;
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
return 0;
}
delete_reflog(old_branch_info->path);
}
}
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, !opts->quiet);
strbuf_release(&msg);
if (!opts->quiet &&
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
if (reset_head(NULL, "reset", NULL, RESET_HEAD_HARD,
NULL, NULL) < 0)
die(_("could not discard worktree changes"));
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
if (read_basic_state(&options))
exit(1);
goto run_rebase;
NULL, NULL) < 0)
die(_("could not move back to %s"),
oid_to_hex(&options.orig_head));
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
ret = finish_rebase(&options);
goto cleanup;
}
print_new_head_line(lookup_commit_reference(the_repository, &oid));
}
if (!pathspec.nr)
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
return update_ref_status;
}
if (cmd == 'q') {
int ret = sequencer_remove_state(opts);
if (!ret)
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
return ret;
}
if (cmd == 'c')