]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/checkout.c
switch: reject if some operation is in progress
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 29 Mar 2019 10:39:15 +0000 (17:39 +0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2019 04:57:00 +0000 (13:57 +0900)
commitc45f0f525de4701b8ff031d5c2c58c0fa819038e
tree1b3d321b6c3e269162c36e7463c0ed6e873fa7ca
parent65f099b3988198f0fdf3ef7a21dc01c556d21fff
switch: reject if some operation is in progress

Unless you know what you're doing, switching to another branch to do
something then switching back could be confusing. Worse, you may even
forget that you're in the middle of something. By the time you realize,
you may have done a ton of work and it gets harder to go back.

A new option --ignore-in-progress was considered but dropped because it
was not exactly clear what should happen. Sometimes you can switch away
and get back safely and resume the operation. Sometimes not. And the
git-checkout behavior is automatically clear merge/revert/cherry-pick,
which makes it a bit even more confusing [1].

We may revisit and add this option in the future. But for now play it
safe and not allow it (you can't even skip this check with --force). The
user is suggested to cancel the operation by themselves (and hopefully
they do consider the consequences, not blindly type the command), or to
create a separate worktree instead of switching. The third option is
the good old "git checkout", but it's not mentioned.

[1] 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>
builtin/checkout.c