Merge branch 'nd/checkout-disambiguation'
"git checkout <word>" does not follow the usual disambiguation rules when the <word> can be both a rev and a path, to allow checking out a branch 'foo' in a project that happens to have a file 'foo' in the working tree without having to disambiguate. This was poorly documented and the check was incorrect when the command was run from a subdirectory. * nd/checkout-disambiguation: checkout: fix ambiguity check in subdir checkout.txt: document a common case that ignores ambiguation rules checkout: add some spaces between code and comment
This commit is contained in:
@ -985,7 +985,7 @@ static int parse_branchname_arg(int argc, const char **argv,
|
||||
int recover_with_dwim = dwim_new_local_branch_ok;
|
||||
|
||||
if (!has_dash_dash &&
|
||||
(check_filename(NULL, arg) || !no_wildcard(arg)))
|
||||
(check_filename(opts->prefix, arg) || !no_wildcard(arg)))
|
||||
recover_with_dwim = 0;
|
||||
/*
|
||||
* Accept "git checkout foo" and "git checkout foo --"
|
||||
@ -1038,7 +1038,7 @@ static int parse_branchname_arg(int argc, const char **argv,
|
||||
|
||||
if (!*source_tree) /* case (1): want a tree */
|
||||
die(_("reference is not a tree: %s"), arg);
|
||||
if (!has_dash_dash) {/* case (3).(d) -> (1) */
|
||||
if (!has_dash_dash) { /* case (3).(d) -> (1) */
|
||||
/*
|
||||
* Do not complain the most common case
|
||||
* git checkout branch
|
||||
@ -1046,7 +1046,7 @@ static int parse_branchname_arg(int argc, const char **argv,
|
||||
* it would be extremely annoying.
|
||||
*/
|
||||
if (argc)
|
||||
verify_non_filename(NULL, arg);
|
||||
verify_non_filename(opts->prefix, arg);
|
||||
} else {
|
||||
argcount++;
|
||||
argv++;
|
||||
|
Reference in New Issue
Block a user