Typo & grammar fixes suggested by Eric Sunshine. tbdiff from v5: 1: ab4529d9f5 = 1: ab4529d9f5 checkout tests: index should be clean after dwim checkout 2: c8bbece403 = 2: c8bbece403 checkout.h: wrap the arguments to unique_tracking_name() 3: 4fc5ab27fa ! 3: 881fe63f4f checkout.c: introduce an *_INIT macro @@ -1,6 +1,6 @@ Author: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> - checkout.[ch]: introduce an *_INIT macro + checkout.c: introduce an *_INIT macro Add an *_INIT macro for the tracking_name_data similar to what exists elsewhere in the codebase, e.g. OID_ARRAY_INIT in sha1-array.h. This 4: fbce6df584 ! 4: 72ddaeddd3 checkout.c]: change "unique" member to "num_matches" @@ -1,6 +1,6 @@ Author: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> - checkout.[ch]: change "unique" member to "num_matches" + checkout.c]: change "unique" member to "num_matches" Internally track how many matches we find in the check_tracking_name() callback. Nothing uses this now, but it will be made use of in a later 5: 6e016d43d7 = 5: 5e8c82680b checkout: pass the "num_matches" up to callers 6: 07b11b133d = 6: 07e667f80a builtin/checkout.c: use "ret" variable for return 7: 97e84f6e1c ! 7: 0a148182e6 checkout: add advice for ambiguous "checkout <branch>" @@ -8,9 +8,9 @@ exactly one remote (call it <remote>) with a matching name, treat as equivalent to [...] <remote>/<branch. - This is a really useful feature. The problem is that when you and - another remote (e.g. a fork) git won't find a unique branch name - anymore, and will instead print this nondescript message: + This is a really useful feature. The problem is that when you add + another remote (e.g. a fork), git won't find a unique branch name + anymore, and will instead print this unhelpful message: $ git checkout master error: pathspec 'master' did not match any file(s) known to git @@ -19,12 +19,12 @@ $ ./git --exec-path=$PWD checkout master error: pathspec 'master' did not match any file(s) known to git. - hint: The argument 'master' matched more than one remote tracking branch. + hint: 'master' matched more than one remote tracking branch. hint: We found 26 remotes with a reference that matched. So we fell back hint: on trying to resolve the argument as a path, but failed there too! hint: - hint: If you meant to check out a remote tracking branch on e.g. 'origin' - hint: you can do so by fully-qualifying the name with the --track option: + hint: If you meant to check out a remote tracking branch on, e.g. 'origin', + hint: you can do so by fully qualifying the name with the --track option: hint: hint: git checkout --track origin/<name> @@ -97,12 +97,12 @@ int ret = checkout_paths(&opts, new_branch_info.name); + if (ret && dwim_remotes_matched > 1 && + advice_checkout_ambiguous_remote_branch_name) -+ advise(_("The argument '%s' matched more than one remote tracking branch.\n" ++ advise(_("'%s' matched more than one remote tracking branch.\n" + "We found %d remotes with a reference that matched. So we fell back\n" + "on trying to resolve the argument as a path, but failed there too!\n" + "\n" -+ "If you meant to check out a remote tracking branch on e.g. 'origin'\n" -+ "you can do so by fully-qualifying the name with the --track option:\n" ++ "If you meant to check out a remote tracking branch on, e.g. 'origin',\n" ++ "you can do so by fully qualifying the name with the --track option:\n" + "\n" + " git checkout --track origin/<name>"), + argv[0], 8: a5cc070ebf ! 8: f3a52a26a2 checkout & worktree: introduce checkout.defaultRemote @@ -175,8 +175,8 @@ * (c) Otherwise, if "--" is present, treat it like case (1). * @@ - "If you meant to check out a remote tracking branch on e.g. 'origin'\n" - "you can do so by fully-qualifying the name with the --track option:\n" + "If you meant to check out a remote tracking branch on, e.g. 'origin',\n" + "you can do so by fully qualifying the name with the --track option:\n" "\n" - " git checkout --track origin/<name>"), + " git checkout --track origin/<name>\n" Ævar Arnfjörð Bjarmason (8): checkout tests: index should be clean after dwim checkout checkout.h: wrap the arguments to unique_tracking_name() checkout.c: introduce an *_INIT macro checkout.c]: change "unique" member to "num_matches" checkout: pass the "num_matches" up to callers builtin/checkout.c: use "ret" variable for return checkout: add advice for ambiguous "checkout <branch>" checkout & worktree: introduce checkout.defaultRemote Documentation/config.txt | 26 +++++++++++++++ Documentation/git-checkout.txt | 9 ++++++ Documentation/git-worktree.txt | 9 ++++++ advice.c | 2 ++ advice.h | 1 + builtin/checkout.c | 41 ++++++++++++++++++----- builtin/worktree.c | 4 +-- checkout.c | 37 ++++++++++++++++++--- checkout.h | 4 ++- t/t2024-checkout-dwim.sh | 59 ++++++++++++++++++++++++++++++++++ t/t2025-worktree-add.sh | 21 ++++++++++++ 11 files changed, 197 insertions(+), 16 deletions(-) -- 2.17.0.290.gded63e768a