-
Notifications
You must be signed in to change notification settings - Fork 70
Add :linear filter #741
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
Add :linear filter #741
Conversation
d3e88fc to
0000bda
Compare
| ### Linearize history **:linear** | ||
| Produce a filtered history that does not contain any merge commits. This is done by | ||
| simply dropping all parents except the first on every commit. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a few words on a typical use case?
Change-Id: linear-filter
0000bda to
cdc44e3
Compare
LMG
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, just a few questions to understand the implementation
| Squash, | ||
| Paths, | ||
| Squash, | ||
| Linear, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alphabetical order?
| } | ||
| let parent = some_or!(apply_to_commit2(op, &p[0], transaction)?, { | ||
| return Ok(None); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning Ok(None) from this function means that we cannot produce filtered commit right now because one of the parents was not filtered yet. In order to not recuruse here to filter the parent we return and will get called again at a later point when the parent has been filtered.
| ) -> JoshResult<git2::Tree<'a>> { | ||
| return match op { | ||
| Op::Nop => Ok(tree), | ||
| Op::Linear => Ok(tree), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that it works, but I don't understand why. How does it find the parents after this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic 🪄
Just like with any other filter: When we need to find the original commits we search them by traversing the commit graph until we find apply(sha) == filtered_sha.
Many filters drop commits, how exactly does not matter for the algorithm to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Thinking about it more, this didn't confuse me on other filters, but for some reason I got stuck on this one :)
No description provided.