Skip to content

Commit 3ff6af7

Browse files
committed
Merge branch 'nd/switch-and-restore'
Resurrect a performance hack. * nd/switch-and-restore: checkout: add simple check for 'git checkout -b'
2 parents aadac06 + 3136776 commit 3ff6af7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

builtin/checkout.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
17081708
opts.checkout_index = -2; /* default on */
17091709
opts.checkout_worktree = -2; /* default on */
17101710

1711+
if (argc == 3 && !strcmp(argv[1], "-b")) {
1712+
/*
1713+
* User ran 'git checkout -b <branch>' and expects
1714+
* the same behavior as 'git switch -c <branch>'.
1715+
*/
1716+
opts.switch_branch_doing_nothing_is_ok = 0;
1717+
opts.only_merge_on_switching_branches = 1;
1718+
}
1719+
17111720
options = parse_options_dup(checkout_options);
17121721
options = add_common_options(&opts, options);
17131722
options = add_common_switch_branch_options(&opts, options);

0 commit comments

Comments
 (0)