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

Don't sort hunks based on dest_commit. #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rbartlensky
Copy link
Contributor

Hey!

I kept running into #116 and I finally had some time to sit down and bisect with a small repro I had available. I haven't tested with the repro from #116 but I believe it is the same issue.

I hope I'll have some time in the next {weeks|months} to open a PR to fix the now broken --one-fixup-per-commit feature (not 100% broken, but it doesn't work as advertised in some cases) and add some tests to catch such issues in the future.

Because each hunk needs to be displaced based on the previously
applied hunk, sorting hunks will change the order in which they are
applied, therefore undoing all our previous calculations.

This fixes tummychow#116, but breaks the --one-fixup-per-commit feature in
cases where there is an odd hunk in between some hunks that could've
been merged together.
@tummychow
Copy link
Owner

ah, thanks for your investigation. probably we have to commute the hunks to correct their line offsets while sorting them...

@rbartlensky
Copy link
Contributor Author

rbartlensky commented Oct 19, 2024

ah, thanks for your investigation. probably we have to commute the hunks to correct their line offsets while sorting them...

Another idea I had the other day was to change the main loop from:

for patch in patches {
  for hunk in hunks {
    for commit in stack {
    }
  }
}

to

for commit in stack {
  for patch in patches {
    for hunk in hunks {
    }
  }
}

and that way we can keep the same logic, and in the end the fixups will be sorted already by commit. However, it's easier said than done, since I have to move a lot of code around, which might introduce even more bugs if I'm not careful. Moreover I'm not familiar enough with the code to know whether changing the ordering might have other side-effects that I'm not seeing.

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

Successfully merging this pull request may close these issues.

2 participants