Skip to content

pr-2349/0xABAN/rm-staged-worktree-v1

tagged this 05 Dec 07:19
RFC: I'd like feedback on some design choices below.

rm uses --cached while some (newer) commands like restore use --staged. In
[1], a discussion raised this confusion, advocating for an alias. Junio
objected, saying it adds nothing unless rm gets a working-tree-only target.
This series introduces a working-tree-only target for rm and aims to restart
conversations about a wider push to --staged in user-facing commands (see
question #2 below). It also makes --cached an alias for --staged & preserves
existing default behaviors.

Open questions:

 1. How to handle git rm --worktree attempts? There are three approaches:
    (1) remove the working tree & keep .gitmodules; (2) remove the working
    tree & remove the .gitmodules entry; (3) refuse the request. (1) could
    work but it duplicates git submodule deinit, (2) modifies the index,
    which is probably wrong for a flag that aims to be "worktree-only." I
    chose (3) and added a hint to use git submodule deinit instead since
    that's the more explicit command.

 2. In [2], Duy stated:

    >  * 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'.

    While this series only introduces the feature for rm, I generally agree
    with this. It makes --worktree and --staged the standard, which reduces
    the friction you'd expect while using Git. I have the bandwidth to pick
    them up, but I wanted to draw some feedback before attempting it.

[1] https://lore.kernel.org/git/xmqq4l73ztxf.fsf@gitster-ct.c.googlers.com/
[2] https://lore.kernel.org/git/20190425094600.15673-1-pclouds@gmail.com/

adam torres encarnacion (2):
  rm: add --staged and --worktree
  rm: relax --worktree-only restrictions

 Documentation/git-rm.adoc | 41 ++++++++++++--------
 builtin/rm.c              | 71 ++++++++++++++++++++++++-----------
 t/t3600-rm.sh             | 79 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 150 insertions(+), 41 deletions(-)

base-commit: 566b6997dd4710b625c0882cf10a7443bf52d183

Submitted-As: https://lore.kernel.org/git/pull.2349.git.1796455144.gitgitgadget@gmail.com
Assets 2
Loading