@@ -1544,6 +1544,9 @@ static struct option *add_checkout_path_options(struct checkout_opts *opts,
15441544 return newopts ;
15451545}
15461546
1547+ /* create-branch option (either b or c) */
1548+ static char cb_option = 'b' ;
1549+
15471550static int checkout_main (int argc , const char * * argv , const char * prefix ,
15481551 struct checkout_opts * opts , struct option * options ,
15491552 const char * const usagestr [])
@@ -1586,7 +1589,8 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
15861589 }
15871590
15881591 if ((!!opts -> new_branch + !!opts -> new_branch_force + !!opts -> new_orphan_branch ) > 1 )
1589- die (_ ("-b, -B and --orphan are mutually exclusive" ));
1592+ die (_ ("-%c, -%c and --orphan are mutually exclusive" ),
1593+ cb_option , toupper (cb_option ));
15901594
15911595 if (opts -> overlay_mode == 1 && opts -> patch_mode )
15921596 die (_ ("-p and --overlay are mutually exclusive" ));
@@ -1614,15 +1618,15 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
16141618 /*
16151619 * From here on, new_branch will contain the branch to be checked out,
16161620 * and new_branch_force and new_orphan_branch will tell us which one of
1617- * -b/-B/--orphan is being used.
1621+ * -b/-B/-c/-C/- -orphan is being used.
16181622 */
16191623 if (opts -> new_branch_force )
16201624 opts -> new_branch = opts -> new_branch_force ;
16211625
16221626 if (opts -> new_orphan_branch )
16231627 opts -> new_branch = opts -> new_orphan_branch ;
16241628
1625- /* --track without -b/-B/--orphan should DWIM */
1629+ /* --track without -c/-C/- b/-B/--orphan should DWIM */
16261630 if (opts -> track != BRANCH_TRACK_UNSPECIFIED && !opts -> new_branch ) {
16271631 const char * argv0 = argv [0 ];
16281632 if (!argc || !strcmp (argv0 , "--" ))
@@ -1631,7 +1635,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
16311635 skip_prefix (argv0 , "remotes/" , & argv0 );
16321636 argv0 = strchr (argv0 , '/' );
16331637 if (!argv0 || !argv0 [1 ])
1634- die (_ ("missing branch name; try -b" ) );
1638+ die (_ ("missing branch name; try -%c" ), cb_option );
16351639 opts -> new_branch = argv0 + 1 ;
16361640 }
16371641
@@ -1822,6 +1826,8 @@ int cmd_switch(int argc, const char **argv, const char *prefix)
18221826 options = add_common_options (& opts , options );
18231827 options = add_common_switch_branch_options (& opts , options );
18241828
1829+ cb_option = 'c' ;
1830+
18251831 ret = checkout_main (argc , argv , prefix , & opts ,
18261832 options , switch_branch_usage );
18271833 FREE_AND_NULL (options );
0 commit comments