Skip to content

Conversation

@christian-schilling
Copy link
Member

No description provided.

@christian-schilling christian-schilling changed the title @changes/master/christian.schilling.de@gmail.com/linear filter Add :linear filter May 18, 2022
@christian-schilling christian-schilling force-pushed the @changes/master/christian.schilling.de@gmail.com/linear-filter branch from d3e88fc to 0000bda Compare May 18, 2022 11:50
@christian-schilling christian-schilling requested a review from LMG May 18, 2022 12:11
### 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.

Copy link
Collaborator

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
@christian-schilling christian-schilling force-pushed the @changes/master/christian.schilling.de@gmail.com/linear-filter branch from 0000bda to cdc44e3 Compare May 18, 2022 12:19
Copy link
Collaborator

@LMG LMG left a 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,
Copy link
Collaborator

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);
});
Copy link
Collaborator

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

Copy link
Member Author

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),
Copy link
Collaborator

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?

Copy link
Member Author

@christian-schilling christian-schilling May 18, 2022

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.

Copy link
Collaborator

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 :)

@christian-schilling christian-schilling merged commit 8d80230 into master May 19, 2022
@christian-schilling christian-schilling deleted the @changes/master/christian.schilling.de@gmail.com/linear-filter branch May 19, 2022 09:32
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.

3 participants