Skip to content

Commit

Permalink
Merge branch 'nd/switch-and-restore'
Browse files Browse the repository at this point in the history
Resurrect a performance hack.

* nd/switch-and-restore:
  checkout: add simple check for 'git checkout -b'
  • Loading branch information
gitster committed Sep 30, 2019
2 parents aadac06 + 3136776 commit 3ff6af7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
opts.checkout_index = -2; /* default on */
opts.checkout_worktree = -2; /* default on */

if (argc == 3 && !strcmp(argv[1], "-b")) {
/*
* User ran 'git checkout -b <branch>' and expects
* the same behavior as 'git switch -c <branch>'.
*/
opts.switch_branch_doing_nothing_is_ok = 0;
opts.only_merge_on_switching_branches = 1;
}

options = parse_options_dup(checkout_options);
options = add_common_options(&opts, options);
options = add_common_switch_branch_options(&opts, options);
Expand Down

0 comments on commit 3ff6af7

Please sign in to comment.