Skip to content

Conversation

@cruessler
Copy link
Contributor

@cruessler cruessler commented Jan 4, 2026

This is an experiment that’s supposed to help me validate the gix-blame algorithm. gix-blame currently rests on two foundations: 1. is the algorithm that traverses a file’s history and keeps track of blamed and unblamed hunks. 2. is the algorithm used for diffing subsequent states of a file throughout its history. Basically, (1.) orchestrates gix-blame, using (2.) to do most of the work of following individual lines throughout a file’s history. gix-blame currently doesn’t match git blame in all cases, but we set out to change that in #2308 as we expect most people to want gix-blame to match git blame’s output.

Since the algorithm used for (2.) differs from the one used by git, it has been somewhat challenging to validate (1.) on a large scale as it is quite hard to tell whether a divergence between gix-blame and git blame is due to differences in (1.) or (2.). This PR tries to approach this issue from a different angle, substituting gix-diff in (2.) by just shelling out to git diff. That way, it hopefully becomes much easier to compare gix-blame using gix-diff vs. gix-blame using git diff vs. git blame on the scale of entire repositories.

I’m opening this PR mostly to get CI feedback and to make this work visible. We probably can close it once I’m done with it.

@Byron
Copy link
Member

Byron commented Jan 5, 2026

This is genius, loving it!

If you want, you can also put the git diff shelling behind an experimental Cargo feature toggle, or even a Rustc feature flag.
That way you can turn it on with RUSTFLAGS="--cfg my_custom_flag" (maybe like this, I asked LLM).

That way it might be easier to test in the real world, and we could merge this.

@cruessler
Copy link
Contributor Author

I was hoping that merging behind a flag might be possible and I really like the idea of using RUSTFLAGS! There’s one issue, though, as I had to change the API of gix_blame::file::function::file to include worktree_path as that’s needed by git diff. Is there a way to get worktree_path from any of the other parameters maybe?

@Byron
Copy link
Member

Byron commented Jan 5, 2026

Since the gix based diff definitely has that information, I am surprised it's not readily available. But somewhere, a level up, it must definitely be there, so I think this can be cfg_if'ed on that level, with adjustments to the callsite. It's not super pretty to adjust the call site (one with, and one without the worktree path), but it gets the job done and is probably needed to make this testable in the real world.

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