git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 00/16] Add new command 'restore'

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 25, 2019, 09:45 UTC
Message-ID
<20190425094600.15673-1-pclouds@gmail.com>
In-Reply-To
<20190411131218.19195-1-pclouds@gmail.com>
v3 changes are really small
- gitcli.txt is updated to mention the --staged/--worktree pair, in
  comparison to --cached/--index which is also mention there.
- The patch 'rm --staged' is dropped. It could come back. But if it
  does, it should be in a series where commands that take
  --cached/--index will now take both --staged/--worktree. Those are
  'rm', 'apply', 'check-attr', 'grep', 'diff' and maybe 'ls-files'.
  
  In other words we support --staged/--worktree everywhere while
  --cached/--index still remains because of muscle memory. This is
  of course only a good move if --staged/--worktree is much better
  than --cached/--index.
- Since there's a chance this series may end up in 'master' and get
  released, and I'm still worried that I screwed up somewhere, the last
  patch declares the two commands experimental for maybe one or two
  release cycles.
  
  If the reception is good, we revert that patch. If something
  horrible is found, we can still change the default behavior without
  anybody yelling at us. Or worst case scenario, we remove both
  commands and declare a failed experiment.

PS. the intent-to-add support is still not in. But it should be in before the experimental status is removed.

Nguyễn Thái Ngọc Duy (16):
  checkout: split part of it to new command 'restore'
  restore: take tree-ish from --source option instead
  restore: make pathspec mandatory
  restore: disable overlay mode by default
  checkout: factor out worktree checkout code
  restore: add --worktree and --staged
  restore: reject invalid combinations with --staged
  restore: default to --source=HEAD when only --staged is specified
  restore: replace --force with --ignore-unmerged
  restore: support --patch
  t: add tests for restore
  completion: support restore
  user-manual.txt: prefer 'merge --abort' over 'reset --hard'
  doc: promote "git restore"
  help: move git-diff and git-reset to different groups
  Declare both git-switch and git-restore experimental
 .gitignore                             |   1 +
 Documentation/config/interactive.txt   |   3 +-
 Documentation/git-checkout.txt         |   3 +-
 Documentation/git-clean.txt            |   2 +-
 Documentation/git-commit.txt           |   2 +-
 Documentation/git-format-patch.txt     |   2 +-
 Documentation/git-reset.txt            |  13 +-
 Documentation/git-restore.txt (new)    | 185 +++++++++++++++
 Documentation/git-revert.txt           |   7 +-
 Documentation/git-switch.txt           |   2 +
 Documentation/git.txt                  |  20 ++
 Documentation/gitcli.txt               |  16 +-
 Documentation/giteveryday.txt          |   5 +-
 Documentation/gittutorial-2.txt        |   4 +-
 Documentation/gittutorial.txt          |   2 +-
 Documentation/user-manual.txt          |  14 +-
 Makefile                               |   1 +
 builtin.h                              |   1 +
 builtin/checkout.c                     | 299 +++++++++++++++++++------
 builtin/clone.c                        |   2 +-
 builtin/commit.c                       |   2 +-
 command-list.txt                       |   7 +-
 contrib/completion/git-completion.bash |  15 ++
 git-add--interactive.perl              |  52 +++++
 git.c                                  |   1 +
 t/lib-patch-mode.sh                    |  12 +
 t/t2070-restore.sh (new +x)            |  99 ++++++++
 t/t2071-restore-patch.sh (new +x)      | 110 +++++++++
 t/t7508-status.sh                      |  82 +++----
 t/t7512-status-help.sh                 |  20 +-
 wt-status.c                            |  26 ++-
 31 files changed, 850 insertions(+), 160 deletions(-)
 create mode 100644 Documentation/git-restore.txt
 create mode 100755 t/t2070-restore.sh
 create mode 100755 t/t2071-restore-patch.sh
Range-diff dựa trên v2:
 1:  41788fc2d2 !  1:  0d5ea2b7fe checkout: split part of it to new command 'restore'
    @@ -342,6 +342,29 @@
      Low-level commands (plumbing)
      -----------------------------
     
    + diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt
    + --- a/Documentation/gitcli.txt
    + +++ b/Documentation/gitcli.txt
    +@@
    + http://marc.info/?l=git&m=119150393620273 for further
    + information.
    + 
    ++Some other commands that also work on files in the working tree and/or
    ++in the index can take `--staged` and/or `--worktree`.
    ++
    ++* `--staged` is exactly like `--cached`, which is used to ask a
    ++  command to only work on the index, not the working tree.
    ++
    ++* `--worktree` is the opposite, to ask a command to work on the
    ++  working tree only, not the index.
    ++
    ++* The two options can be specified together to ask a command to work
    ++  on both the index and the working tree.
    ++
    + GIT
    + ---
    + Part of the linkgit:git[1] suite
    +
      diff --git a/Makefile b/Makefile
      --- a/Makefile
      +++ b/Makefile
 2:  253dfb42ae =  2:  c3c6e7762a restore: take tree-ish from --source option instead
 3:  0266c4d982 =  3:  0fbf963e7d restore: make pathspec mandatory
 4:  ae4dd4c24e =  4:  2509bebf32 restore: disable overlay mode by default
 5:  c51dd232c0 =  5:  206c507f7d checkout: factor out worktree checkout code
 6:  6b19ddb1b3 =  6:  656bfcd659 restore: add --worktree and --staged
 7:  3f1031cc23 =  7:  f2d3aa1027 restore: reject invalid combinations with --staged
 8:  d6d9bed95c =  8:  57efad405d restore: default to --source=HEAD when only --staged is specified
 9:  fca91f3cca =  9:  3c6b32c223 restore: replace --force with --ignore-unmerged
10:  079273e2df = 10:  6665d7523b restore: support --patch
11:  9d28d167fa = 11:  d7bda0c0cc t: add tests for restore
12:  acd490f8b0 = 12:  e4622aff3d completion: support restore
13:  336a7d8921 = 13:  787b0e485e user-manual.txt: prefer 'merge --abort' over 'reset --hard'
14:  3b81b27255 = 14:  0df020c2c8 doc: promote "git restore"
15:  ce7e890524 <  -:  ---------- rm: add --staged as alias for --cached
16:  763aa1d6f1 = 15:  3302b1b0e1 help: move git-diff and git-reset to different groups
 -:  ---------- > 16:  ffeea858a7 Declare both git-switch and git-restore experimental
-- 
2.21.0.854.ge34a79f761
Previous: Duy NguyenNext: Nguyễn Thái Ngọc Duy
Message 75 of 97 in “And new command "restore"”
  1. 00/11 And new command "restore"Nguyễn Thái Ngọc Duy, Mar 8, 2019
  2. 01/11 checkout: split part of it to new command 'restore'Nguyễn Thái Ngọc Duy, Mar 8, 2019
  3. Elijah NewrenMar 8, 2019
  4. Duy NguyenMar 9, 2019
  5. Elijah NewrenMar 9, 2019
  6. Duy NguyenApr 9, 2019
  7. Duy NguyenMar 25, 2019
  8. Elijah NewrenMar 25, 2019
  9. Johannes SchindelinMar 13, 2019
  10. 02/11 restore: take tree-ish from --source option insteadNguyễn Thái Ngọc Duy, Mar 8, 2019
  11. Elijah NewrenMar 9, 2019
  12. Eric SunshineMar 10, 2019
  13. 03/11 restore: make pathspec mandatoryNguyễn Thái Ngọc Duy, Mar 8, 2019
  14. Elijah NewrenMar 9, 2019
  15. 04/11 restore: disable overlay mode by defaultNguyễn Thái Ngọc Duy, Mar 8, 2019
  16. Elijah NewrenMar 9, 2019
  17. 05/11 checkout: factor out worktree checkout codeNguyễn Thái Ngọc Duy, Mar 8, 2019
  18. 06/11 restore: add --worktree and --indexNguyễn Thái Ngọc Duy, Mar 8, 2019
  19. Elijah NewrenMar 9, 2019
  20. Eric SunshineMar 10, 2019
  21. Duy NguyenMar 13, 2019
  22. Junio C HamanoMar 13, 2019
  23. 07/11 restore: default to --source=HEAD when only --index is specifiedNguyễn Thái Ngọc Duy, Mar 8, 2019
  24. Elijah NewrenMar 9, 2019
  25. 08/11 restore: support --patchNguyễn Thái Ngọc Duy, Mar 8, 2019
  26. Elijah NewrenMar 9, 2019
  27. 09/11 t: add tests for restoreNguyễn Thái Ngọc Duy, Mar 8, 2019
  28. Andrei RybakMar 9, 2019
  29. Johannes SchindelinMar 13, 2019
  30. Duy NguyenMar 13, 2019
  31. Johannes SchindelinMar 13, 2019
  32. Duy NguyenMar 14, 2019
  33. Junio C HamanoMar 14, 2019
  34. Junio C HamanoMar 14, 2019
  35. 10/11 completion: support restoreNguyễn Thái Ngọc Duy, Mar 8, 2019
  36. Elijah NewrenMar 9, 2019
  37. Duy NguyenMar 11, 2019
  38. Duy NguyenMar 11, 2019
  39. Elijah NewrenMar 11, 2019
  40. 11/11 doc: promote "git restore"Nguyễn Thái Ngọc Duy, Mar 8, 2019
  41. Elijah NewrenMar 9, 2019
  42. Randall S. BeckerMar 11, 2019
  43. Duy NguyenMar 11, 2019
  44. Junio C HamanoMar 13, 2019
  45. Duy NguyenApr 11, 2019
  46. Duy NguyenMar 10, 2019
  47. Jacob KellerMar 10, 2019
  48. Elijah NewrenMar 11, 2019
  49. Junio C HamanoMar 13, 2019
  50. Duy NguyenMar 14, 2019
  51. 00/16 Add new command 'restore'Nguyễn Thái Ngọc Duy, Apr 11, 2019
  52. 01/16 checkout: split part of it to new command 'restore'Nguyễn Thái Ngọc Duy, Apr 11, 2019
  53. 02/16 restore: take tree-ish from --source option insteadNguyễn Thái Ngọc Duy, Apr 11, 2019
  54. 03/16 restore: make pathspec mandatoryNguyễn Thái Ngọc Duy, Apr 11, 2019
  55. 04/16 restore: disable overlay mode by defaultNguyễn Thái Ngọc Duy, Apr 11, 2019
  56. 05/16 checkout: factor out worktree checkout codeNguyễn Thái Ngọc Duy, Apr 11, 2019
  57. 06/16 restore: add --worktree and --stagedNguyễn Thái Ngọc Duy, Apr 11, 2019
  58. 07/16 restore: reject invalid combinations with --stagedNguyễn Thái Ngọc Duy, Apr 11, 2019
  59. 08/16 restore: default to --source=HEAD when only --staged is specifiedNguyễn Thái Ngọc Duy, Apr 11, 2019
  60. 09/16 restore: replace --force with --ignore-unmergedNguyễn Thái Ngọc Duy, Apr 11, 2019
  61. 10/16 restore: support --patchNguyễn Thái Ngọc Duy, Apr 11, 2019
  62. 11/16 t: add tests for restoreNguyễn Thái Ngọc Duy, Apr 11, 2019
  63. 12/16 completion: support restoreNguyễn Thái Ngọc Duy, Apr 11, 2019
  64. 13/16 user-manual.txt: prefer 'merge --abort' over 'reset --hard'Nguyễn Thái Ngọc Duy, Apr 11, 2019
  65. 14/16 doc: promote "git restore"Nguyễn Thái Ngọc Duy, Apr 11, 2019
  66. 15/16 rm: add --staged as alias for --cachedNguyễn Thái Ngọc Duy, Apr 11, 2019
  67. 16/16 help: move git-diff and git-reset to different groupsNguyễn Thái Ngọc Duy, Apr 11, 2019
  68. Junio C HamanoApr 12, 2019
  69. Duy NguyenApr 13, 2019
  70. Duy NguyenApr 17, 2019
  71. Junio C HamanoApr 18, 2019
  72. Duy NguyenApr 18, 2019
  73. Johannes SchindelinApr 18, 2019
  74. Duy NguyenApr 18, 2019
  75. 00/16 Add new command 'restore'Nguyễn Thái Ngọc Duy, Apr 25, 2019
  76. 01/16 checkout: split part of it to new command 'restore'Nguyễn Thái Ngọc Duy, Apr 25, 2019
  77. 02/16 restore: take tree-ish from --source option insteadNguyễn Thái Ngọc Duy, Apr 25, 2019
  78. 03/16 restore: make pathspec mandatoryNguyễn Thái Ngọc Duy, Apr 25, 2019
  79. 04/16 restore: disable overlay mode by defaultNguyễn Thái Ngọc Duy, Apr 25, 2019
  80. 05/16 checkout: factor out worktree checkout codeNguyễn Thái Ngọc Duy, Apr 25, 2019
  81. 06/16 restore: add --worktree and --stagedNguyễn Thái Ngọc Duy, Apr 25, 2019
  82. 07/16 restore: reject invalid combinations with --stagedNguyễn Thái Ngọc Duy, Apr 25, 2019
  83. 08/16 restore: default to --source=HEAD when only --staged is specifiedNguyễn Thái Ngọc Duy, Apr 25, 2019
  84. 09/16 restore: replace --force with --ignore-unmergedNguyễn Thái Ngọc Duy, Apr 25, 2019
  85. 10/16 restore: support --patchNguyễn Thái Ngọc Duy, Apr 25, 2019
  86. 11/16 t: add tests for restoreNguyễn Thái Ngọc Duy, Apr 25, 2019
  87. SZEDER GáborJun 13, 2019
  88. 12/16 completion: support restoreNguyễn Thái Ngọc Duy, Apr 25, 2019
  89. 13/16 user-manual.txt: prefer 'merge --abort' over 'reset --hard'Nguyễn Thái Ngọc Duy, Apr 25, 2019
  90. 14/16 doc: promote "git restore"Nguyễn Thái Ngọc Duy, Apr 25, 2019
  91. 15/16 help: move git-diff and git-reset to different groupsNguyễn Thái Ngọc Duy, Apr 25, 2019
  92. 16/16 Declare both git-switch and git-restore experimentalNguyễn Thái Ngọc Duy, Apr 25, 2019
  93. Emily ShafferMay 7, 2019
  94. Junio C HamanoMay 7, 2019
  95. Duy NguyenMay 7, 2019
  96. Emily ShafferMay 7, 2019
  97. Duy NguyenMay 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.