summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-09-30 04:19:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-09-30 04:19:27 (GMT)
commit3ff6af7753287f2cac8261ae5184c3381373b836 (patch)
treec8270adad0caf921e4ae592f9d80a77e887bdc3c /builtin/checkout.c
parentaadac067aa34a148477c9db98058941be3e4465c (diff)
parent313677627a8258a0a936136938302b244ae5511c (diff)
downloadgit-3ff6af7753287f2cac8261ae5184c3381373b836.zip
git-3ff6af7753287f2cac8261ae5184c3381373b836.tar.gz
git-3ff6af7753287f2cac8261ae5184c3381373b836.tar.bz2
Merge branch 'nd/switch-and-restore'
Resurrect a performance hack. * nd/switch-and-restore: checkout: add simple check for 'git checkout -b'
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0a3679e..1283727 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -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);