summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--branch.c11
-rw-r--r--branch.h2
-rw-r--r--builtin/am.c2
-rw-r--r--builtin/checkout.c2
-rw-r--r--builtin/rebase.c4
-rw-r--r--builtin/reset.c2
-rw-r--r--builtin/revert.c2
7 files changed, 14 insertions, 11 deletions
diff --git a/branch.c b/branch.c
index 28b81a7..8dd5bb9 100644
--- 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));
diff --git a/branch.h b/branch.h
index 29c1afa..aed0459 100644
--- a/branch.h
+++ b/branch.h
@@ -64,7 +64,7 @@ extern int validate_new_branchname(const char *name, struct strbuf *ref, int for
* 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"
diff --git a/builtin/am.c b/builtin/am.c
index 4fb107a..99b6650 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1957,7 +1957,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
if (merge_tree(remote_tree))
return -1;
- remove_branch_state(the_repository);
+ remove_branch_state(the_repository, 0);
return 0;
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0e6037b..f66bd2f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -899,7 +899,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
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"))))
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 52114cb..646d0f9 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1272,7 +1272,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
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;
@@ -1292,7 +1292,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
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;
}
diff --git a/builtin/reset.c b/builtin/reset.c
index 7882829..6d9397c 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -420,7 +420,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
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;
}
diff --git a/builtin/revert.c b/builtin/revert.c
index a47b53c..ebf2789 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -196,7 +196,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
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')