Skip to content

Commit d16dc42

Browse files
pcloudsgitster
authored andcommitted
switch: allow to switch in the middle of bisect
In c45f0f5 (switch: reject if some operation is in progress, 2019-03-29), a check is added to prevent switching when some operation is in progress. The reason is it's often not safe to do so. This is true for merge, am, rebase, cherry-pick and revert, but not so much for bisect because bisecting is basically jumping/switching between a bunch of commits to pin point the first bad one. git-bisect suggests the next commit to test, but it's not wrong for the user to test a different commit because git-bisect cannot have the knowledge to know better. For this reason, allow to switch when bisecting (*). I considered if we should still prevent switching by default and allow it with --ignore-in-progress. But I don't think the prevention really adds anything much. If the user switches away by mistake, since we print the previous HEAD value, even if they don't know about the "-" shortcut, switching back is still possible. The warning will be printed on every switch while bisect is still ongoing, not the first time you switch away from bisect's suggested commit, so it could become a bit annoying. (*) of course when it's safe to do so, i.e. no loss of local changes and stuff. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bcba406 commit d16dc42

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

builtin/checkout.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,7 @@ static void die_if_some_operation_in_progress(void)
13261326
"Consider \"git revert --quit\" "
13271327
"or \"git worktree add\"."));
13281328
if (state.bisect_in_progress)
1329-
die(_("cannot switch branch while bisecting\n"
1330-
"Consider \"git bisect reset HEAD\" "
1331-
"or \"git worktree add\"."));
1329+
warning(_("you are switching branch while bisecting"));
13321330
}
13331331

13341332
static int checkout_branch(struct checkout_opts *opts,

0 commit comments

Comments
 (0)