hartwork / git-delete-merged-branches

:fire: Command-line tool to delete merged Git branches
https://pypi.org/project/git-delete-merged-branches/
GNU General Public License v3.0
880 stars 15 forks source link

[feature] Don't try to delete branches that are checked out in so-called "linked working trees" (git-worktree) #43

Closed SuperSandro2000 closed 3 years ago

SuperSandro2000 commented 3 years ago

When branches staged for deletion are checkout in worktrees the command fails and gdmb aborts.

result/bin/git-delete-merged-branches
Do you want to run "git remote update --prune" for 1 remote(s):
- origin

Update? [y/N] y

Skipped refreshing branches due to uncommitted changes.
Skipped branch 'openipmi' because it is currently checked out.
You are about to delete 56 local branch(es):
  - asciidoc
  - auto-update/python3.7-flake8-debugger
...
  - use-asciidoctor-for-git-docs
  - wezterm-01

Delete? [y/N] y
error: Cannot delete branch 'bump-google' checked out at '/home/hotpi/src/nixpkgs3'
error: Cannot delete branch 'flow' checked out at '/home/hotpi/src/nixpkgs5'
error: Cannot delete branch 'nvim-fallout' checked out at '/home/hotpi/src/nixpkgs4'

Error: Command 'git branch --delete bump-google flow nvim-fallout' returned non-zero exit status 1.

Those branches should be skipped instead.

hartwork commented 3 years ago

Hi @SuperSandro2000 ,

this is the first time I hear of git-worktree — is that feature of Git what it's about? At the moment, I consider this an enhancement rather than a bugfix and will research possible options with regard to this feature of Git.

Best, Sebastian

SuperSandro2000 commented 3 years ago

git-worktree allows you to create an extra directory on a different branch which shares the entire .git directory and by this speeds up "cloning" by a lot for big repositories. It is heavily used by nixpkgs-review and myself to work on multiple little projects within nixpkgs at the same time. It is part of the default git installation and requires no extra installation steps. You should already have it locally on your machine.

hartwork commented 3 years ago

That matches what I skip-read and understood about it today so far. I just heard about it first today and you're the first asking, so that's why it's not supported in git-delete-merged-branches, yet.

hartwork commented 3 years ago

@SuperSandro2000 could you give pull request #44 a spin in your environment to see if the new support for linked working trees works as you would expect?

hartwork commented 3 years ago

@SuperSandro2000 the faster you can give it a spin, the faster I can put it into a release, hint hint :smile:

hartwork commented 3 years ago

@SuperSandro2000 release 6.4.0 with PR #44 included pushed to PyPI just now

SuperSandro2000 commented 3 years ago

There wasn't any need to rush the release. I am managing all my development tools with nix and including patches for packages is pretty damn easy.

hartwork commented 3 years ago

There wasn't any need to rush the release. I am managing all my development tools with nix and including patches for packages is pretty damn easy.

There was no rush. PyPI releases are cheap and quick, and without a release the PR doesn't get to the users. Release early and often if you can. While adding patches to packages may be easy, a patch count of zero is ideal in packaging. I'd be very surprised, if NixOS was any different on that front.

SuperSandro2000 commented 3 years ago

I'd be very surprised, if NixOS was any different on that front.

I patched it out of tree in my dotfiles but getting it to everyone is also important.