Skip to content

Introduce new commands switch-branch and restore-files

Nguyễn Thái Ngọc Duy git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest14 patches 33 repliesIn review
  2. v27 patches 31 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14git-checkout.txt: fix one syntax lineDocumentation/git-checkout.txt+1 -10 replies
2/14git-checkout.txt: split detached head section outDocumentation/detach-head.txt Documentation/git-checkout.txt+133 -1320 replies
3/14checkout: factor out some code in parse_branchname_arg()builtin/checkout.c+31 -200 replies
4/14checkout: make "opts" in cmd_checkout() a pointerbuiltin/checkout.c+55 -540 replies
5/14checkout: move 'confict_style' and 'dwim_..' to checkout_optsbuiltin/checkout.c+9 -70 replies
6/14checkout: split options[] array in three piecesbuiltin/checkout.c parse-options-cb.c parse-options.h+73 -230 replies
7/14checkout: split into switch-branch and restore-files.gitignore Documentation/git-checkout.txt Documentation/git-restore-files.txt +6 more+543 -1210 replies
8/14switch-branch: better names for -b and -Bbuiltin/checkout.c+19 -110 replies
9/14switch-branch: stop accepting pathspecbuiltin/checkout.c+12 -20 replies
10/14switch-branch: reject "do nothing" casebuiltin/checkout.c+10 -00 replies
11/14switch-branch: only allow explicit detached HEADbuiltin/checkout.c+10 -02 replies
12/14restore-files: take tree-ish from --from option insteadbuiltin/checkout.c+34 -70 replies
13/14restore-files: make pathspec mandatorybuiltin/checkout.c+6 -00 replies
14/14doc: promote "git switch-branch" and "git restore-files"Documentation/config/advice.txt Documentation/config/checkout.txt Documentation/git-branch.txt +22 more+104 -970 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH/RFC v3 00/14] Introduce new commands switch-branch and restore-files

v3 sees switch-branch go back to switch-branch (in v2 it was checkout-branch). checkout-files is also renamed restore-files (v1 was restore-paths). Hopefully we won't see another rename.

I'll try to summarize the differences between the new commands and 'git checkout' down here, but you're welcome to just head to 07/14 and read the new man pages.

'git switch-branch'

- does not "do nothing", you have to either switch branch, create a new branch, or detach. "git switch-branch" with no arguments is rejected.

- implicit detaching is rejected. If you need to detach, you need to give --detach. Or stick to 'git checkout'.

- -b/-B is renamed to -c/-C with long option names

- of course does not accept pathspec

'git restore-files'

- takes a ref from --from argument, not as a free ref. As a result, '--' is no longer needed. All non-option arguments are pathspec

- pathspec is mandatory, you can't do "git restore-files" without any pathspec.

- I just remember -p which is allowed to take no pathspec :( I'll fix it later.

- Two more fancy features (the "git checkout --index" being the default mode and the backup log for accidental overwrites) are of course still missing. But they are coming.

I did not go replace "detached HEAD" with "unnamed branch" (or "no branch") everywhere because I think a unique term is still good to refer to this concept. Or maybe "no branch" is good enough. I dunno.

Nguyễn Thái Ngọc Duy (14):
git-checkout.txt: fix one syntax line git-checkout.txt: split detached head section out
checkout: factor out some code in parse_branchname_arg()
checkout: make "opts" in cmd_checkout() a pointer
checkout: move 'confict_style' and 'dwim_..' to checkout_opts
checkout: split options[] array in three pieces
checkout: split into switch-branch and restore-files
switch-branch: better names for -b and -B
switch-branch: stop accepting pathspec
switch-branch: reject "do nothing" case
switch-branch: only allow explicit detached HEAD
restore-files: take tree-ish from --from option instead
restore-files: make pathspec mandatory
doc: promote "git switch-branch" and "git restore-files"

 .gitignore                             |   2 +
 Documentation/config/advice.txt        |  10 +-
 Documentation/config/checkout.txt      |   5 +-
 Documentation/detach-head.txt          | 132 +++++++++
 Documentation/git-branch.txt           |   8 +-
 Documentation/git-check-ref-format.txt |   2 +-
 Documentation/git-checkout.txt         | 140 +--------
 Documentation/git-format-patch.txt     |   2 +-
 Documentation/git-merge-base.txt       |   2 +-
 Documentation/git-rebase.txt           |   2 +-
 Documentation/git-remote.txt           |   2 +-
 Documentation/git-rerere.txt           |  10 +-
 Documentation/git-reset.txt            |  18 +-
 Documentation/git-restore-files.txt    | 167 +++++++++++
 Documentation/git-revert.txt           |   2 +-
 Documentation/git-stash.txt            |   6 +-
 Documentation/git-switch-branch.txt    | 289 +++++++++++++++++++
 Documentation/gitattributes.txt        |   2 +-
 Documentation/gitcli.txt               |   4 +-
 Documentation/gitcore-tutorial.txt     |  18 +-
 Documentation/giteveryday.txt          |  24 +-
 Documentation/githooks.txt             |   5 +-
 Documentation/gittutorial-2.txt        |   2 +-
 Documentation/gittutorial.txt          |   4 +-
 Documentation/revisions.txt            |   2 +-
 Documentation/user-manual.txt          |  54 ++--
 Makefile                               |   2 +
 advice.c                               |  11 +-
 builtin.h                              |   2 +
 builtin/checkout.c                     | 380 ++++++++++++++++++-------
 command-list.txt                       |   4 +-
 git.c                                  |   2 +
 parse-options-cb.c                     |  16 ++
 parse-options.h                        |   3 +-
 sha1-name.c                            |   2 +-
 wt-status.c                            |   2 +-
 36 files changed, 1006 insertions(+), 332 deletions(-)
 create mode 100644 Documentation/detach-head.txt
 create mode 100644 Documentation/git-restore-files.txt
 create mode 100644 Documentation/git-switch-branch.txt
Signature · 1 line
2.20.0.rc1.380.g3eb999425c.dirty