foriequal0 / git-trim

Automatically trims your branches whose tracking remote refs are merged or stray
MIT License
489 stars 14 forks source link

`git-trim` fails when multiple delete filters apply to the same branch #179

Open pmarschik opened 3 years ago

pmarschik commented 3 years ago

Check your version before submitting the bug

$ git-trim -V
git-trim 0.4.2

Describe the bug I have trim.delete = merged-local,merged-remote:origin,stray in my git config. When I git fetch --prune before running git trim and multiple delete filters apply to the same ref name the output is e.g.:

[...]

Delete merged local branches:
  - some-branch
Delete stray local branches:
  - some-branch
Confirm? yes
error: could not delete references: multiple updates for ref 'refs/heads/some-branch' not allowed
error: could not delete references:
Error: Operation not permitted (os error 1)

Steps to reproduce Not actual git-trim reproduction steps but with the git CLI that gets executed by branch_delete:

$ git checkout -b some-branch
$ git checkout -
$ # git-trim behavior
$ git branch --delete --force some-branch some-branch
error: could not delete references: multiple updates for ref 'refs/heads/some-branch' not allowed
error: could not delete references:

Expected behavior branch_names in https://github.com/foriequal0/git-trim/blob/385d8818e3b8db9a73b0f32993f53d1ba0d31386/src/subprocess.rs#L257 should probably be a HashSet instead of Vec so the branches are deleted.

Actual behaviour git subprocess fails.

Additional context and logs & dumps if necessary You should remove sensitive informations before put them here.

foriequal0 commented 3 years ago

Hi @pmarschik ! Thank you for reporting the issue. A branch shouldn't be applied to multiple filters. Sorry to say that I'm a little bit busy at the moment. I'll fix the issue as I have time.