Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work when a branch contains commits that have been applied in more than one merge #12

Open
ggilder opened this issue Jun 16, 2020 · 2 comments

Comments

@ggilder
Copy link

ggilder commented Jun 16, 2020

For example:

  1. I make a branch "develop-B" which is branched off "develop-A"
  2. "develop-A" is squash-merged into main branch
  3. "develop-B" is squash-merged into main branch

Now the approach this script uses (git cherry) fails because there is not a single commit that matches the squashed commit representing "develop-B", it's spread across two commits.

I think that it's possible to fix this and simplify the script by using git merge-tree and git merge-base. Here's an example: https://github.com/ggilder/dotfiles/blob/master/bin/git-delete-merged-branches#L9

@n8gray
Copy link

n8gray commented Jun 29, 2020

@ggilder The approach you're taking in the script you link to won't work in general because it gets broken by subsequent work in the repo.

  • make a branch work that modifies file A
  • squash merge it to master, but don't delete it
  • later merge a different branch to master that deletes file A

Merging work to master at this point will produce a change. Your script would not consider work eligible for deletion, but the one in this repo should.

@ggilder
Copy link
Author

ggilder commented Jul 6, 2020

@n8gray that's a good point, I hadn't considered that scenario. I suppose I might have to run both scripts to cover all the possibilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants