[PATCH 0/3] extend --ignore-other-worktrees to 'rebase', add hints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The old 'workdir' contribution script was removed from git upstream in May
2025, as it is largely superseded by the 'worktree' command.

One significant difference between the old script and the command is that
'git' refuses to checkout or rebase branches that are already checked out in
another worktree. My understanding of the reasoning is that users may be
surprised when a clean worktree becomes dirty as its index is changed from
another worktree. However, this safety net adds a mental burden to worktree
users, as they have to keep the other worktrees in mind when moving
branches. Old goats like me who are used to the old 'workdir' script find
this restriction somewhat painful.

See the discussion thread
  https://lore.kernel.org/git/5580aa89-09f1-426e-8483-c99481c998ab@xxxxxxxxx/
about this transition.

The present patch series tries to provide a smoother migration path for
supporters of worktree independence:

 - when 'checkout' refuses because the branch is used in another worktree,
   display a 'hint' that mentions the possibility of using '--detach'
   instead, and the '--ignore-other-worktrees' option to proceed anyway.

 - add support for '--ignore-other-worktrees' in 'rebase' as well, with
   a similar hint.

In the future I would be interested in adding an option
'branch.ignoreOtherWorktrees' to be able to ignore other worktrees globally.

Note: this is my first experience submitting a patch to the Git project, so
I apologize in advance for any mishap and welcome beginner-level feedback.

Cc: Junio C Hamano <gitster@xxxxxxxxx>
Cc: D. Ben Knoble <ben.knoble@xxxxxxxxx>
Cc: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>

Signed-off-by: Gabriel Scherer <gabriel.scherer@xxxxxxxx>

Gabriel.Scherer (3):
  checkout: provide hint when failing due to another worktree
  rebase: support --ignore-other-worktrees
  rebase: hint when failing on branch used by another worktree

 Documentation/config/advice.adoc |  3 +++
 Documentation/git-rebase.adoc    |  6 ++++++
 advice.c                         |  1 +
 advice.h                         |  1 +
 branch.c                         | 13 +++++++++++--
 branch.h                         |  4 ++++
 builtin/checkout.c               | 12 ++++++++++--
 builtin/rebase.c                 | 19 ++++++++++++++++++-
 t/t3400-rebase.sh                |  4 +++-
 9 files changed, 57 insertions(+), 6 deletions(-)

-- 
2.51.0





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux