Skip to content

ambiguous checkout UI & checkout.defaultRemote

Ævar Arnfjörð Bjarmason git 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest8 patches 1 replyIn review
  2. v68 patches 1 replySuperseded
  3. v58 patches 3 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v49 patches18 repliesSuperseded

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8checkout tests: index should be clean after dwim checkoutt/t2024-checkout-dwim.sh+29 -017 replies
2/8checkout.h: wrap the arguments to unique_tracking_name()checkout.h+2 -10 replies
3/8checkout.c: introduce an *_INIT macrocheckout.c+3 -10 replies
4/8checkout.c: change "unique" member to "num_matches"checkout.c+4 -40 replies
5/8checkout: pass the "num_matches" up to callersbuiltin/checkout.c builtin/worktree.c checkout.c +1 more+15 -70 replies
6/8builtin/checkout.c: use "ret" variable for returnbuiltin/checkout.c+5 -30 replies
7/8checkout: add advice for ambiguous "checkout <branch>"Documentation/config.txt advice.c advice.h +2 more+37 -00 replies
8/8checkout & worktree: introduce checkout.defaultRemoteDocumentation/config.txt Documentation/git-checkout.txt Documentation/git-worktree.txt +4 more+109 -70 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by.

PatchJunio C Hamano
1/8Helped-by Helped-by
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 0/8] ambiguous checkout UI & checkout.defaultRemote

Fixes issues noted with v6, hopefully ready for queuing. A tbdiff with v6:

1: ab4529d9f5 = 1: 2ca81c76fc checkout tests: index should be clean after dwim checkout 2: c8bbece403 = 2: 19b14a1c75 checkout.h: wrap the arguments to unique_tracking_name() 3: 881fe63f4f = 3: 8bc6a9c052 checkout.c: introduce an *_INIT macro
4: 72ddaeddd3 ! 4: 34f3b67f9b checkout.c: change "unique" member to "num_matches"
@@ -1,6 +1,6 @@
Author: Ævar Arnfjörð Bjarmason <[email protected]>

- checkout.c]: 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: 5e8c82680b = 5: 7d81c06a23 checkout: pass the "num_matches" up to callers 6: 07e667f80a = 6: e86636ad2c builtin/checkout.c: use "ret" variable for return 7: 0a148182e6 ! 7: c2130b347c checkout: add advice for ambiguous "checkout <branch>"
@@ -27,6 +27,28 @@
hint: you can do so by fully qualifying the name with the --track option:
hint:
hint: git checkout --track origin/<name>
+
+ Note that the "error: pathspec[...]" message is still printed. This is
+ because whatever else checkout may have tried earlier, its final
+ fallback is to try to resolve the argument as a path. E.g. in this
+ case:
+
+ $ ./git --exec-path=$PWD checkout master pu
+ error: pathspec 'master' did not match any file(s) known to git.
+ error: pathspec 'pu' did not match any file(s) known to git.
+
+ There we don't print the "hint:" implicitly due to earlier logic
+ around the DWIM fallback. That fallback is only used if it looks like
+ we have one argument that might be a branch.
+
+ I can't think of an intrinsic reason for why we couldn't in some
+ future change skip printing the "error: pathspec[...]" error. However,
+ to do so we'd need to pass something down to checkout_paths() to make
+ it suppress printing an error on its own, and for us to be confident
+ that we're not silencing cases where those errors are meaningful.
+
+ I don't think that's worth it since determining whether that's the
+ case could easily change due to future changes in the checkout logic.

8: f3a52a26a2 ! 8: f1ac0f7351 checkout & worktree: introduce checkout.defaultRemote
@@ -53,12 +53,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>
hint:
@@ -263,7 +263,7 @@
status_uno_is_clean &&
- test_i18ngrep ! "^hint: " stderr
+ test_i18ngrep ! "^hint: " stderr &&
-+ # Make sure the likes of checkout -p don not print this hint
++ # Make sure the likes of checkout -p do not print this hint
+ git checkout -p foo 2>stderr &&
+ test_i18ngrep ! "^hint: " stderr &&
+ status_uno_is_clean

Æ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(-)
Signature · 1 line
2.17.0.290.gded63e768a