On Wed, Sep 25, 2013 at 7:49 PM, Matthieu Moy <Matthieu.Moy@xxxxxxx> wrote: > static int parse_branchname_arg(int argc, const char **argv, > int dwim_new_local_branch_ok, > struct branch_info *new, You may want to update the big comment block about all cases at the beginning of this function. > @@ -916,20 +924,28 @@ static int parse_branchname_arg(int argc, const char **argv, > if (!strcmp(arg, "-")) > arg = "@{-1}"; > > - if (get_sha1_mb(arg, rev)) { > - if (has_dash_dash) /* case (1) */ > - die(_("invalid reference: %s"), arg); > - if (dwim_new_local_branch_ok && > - !check_filename(NULL, arg) && > - argc == 1) { > + if (get_sha1_mb(arg, rev)) { /* case (1)? */ > + int try_dwim = dwim_new_local_branch_ok; > + > + if (check_filename(NULL, arg) && !has_dash_dash) > + try_dwim = 0; > + /* > + * Accept "git checkout foo" and "git checkout foo --" > + * as candidates for dwim. > + */ > + if (!(argc == 1 && !has_dash_dash) && has_dash_dash is calculated as (argc > 1) && !strcmp(argv[1], "--"), so when argc == 1, the has_dash_dash must be zero, the "&& !has_dash_dash" is redundant. But it makes me wonder what we do with "git checkout abc def -- xyz". I think both old and new code do not see "--" as a separator like it should (and should also error about multiple refs given). Maybe something worth fixing too while you're updating this code. > + !(argc == 2 && has_dash_dash)) > + try_dwim = 0; > + -- Duy -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html