diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-03-29 13:38:59 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-02 07:56:59 +0300 |
commit | f4a4b9aca3cb70fabe3e856fa61ca35a99e2b8eb (patch) | |
tree | 98ad7f525239f864d4d81fd664261b9e59dc5192 /builtin | |
parent | af9ded5b7007a4fa9844be7ac1c86f7a6ef2e56a (diff) |
checkout: inform the user when removing branch state
After a successful switch, if a merge, cherry-pick or revert is ongoing,
it is canceled. This behavior has been with us from the very early
beginning, soon after git-merge was created but never actually
documented [1]. It may be a good idea to be transparent and tell the
user if some operation is canceled.
I consider this a better way of telling the user than just adding a
sentence or two in git-checkout.txt, which will be mostly ignored
anyway.
PS. Originally I wanted to print more details like
warning: cancelling an in-progress merge from <SHA-1>
which may allow some level of undo if the user wants to. But that seems
a lot more work. Perhaps it can be improved later if people still want
that.
[1] ... and I will try not to argue whether it is a sensible behavior.
There is some more discussion here if people are interested:
CACsJy8Axa5WsLSjiscjnxVK6jQHkfs-gH959=YtUvQkWriAk5w@mail.gmail.com
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 2 | ||||
-rw-r--r-- | builtin/checkout.c | 2 | ||||
-rw-r--r-- | builtin/rebase.c | 4 | ||||
-rw-r--r-- | builtin/reset.c | 2 | ||||
-rw-r--r-- | builtin/revert.c | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/builtin/am.c b/builtin/am.c index 4fb107a9d1..99b66508fd 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 0e6037b296..f66bd2f56d 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 52114cbf0d..646d0f9fb1 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 7882829a95..6d9397c844 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 a47b53ceaf..ebf2789225 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') |