Post #958820
2026-04-06 10:21 UTC
Dear semi-lazyweb,
Given a git diff of a C/Rust codebase, how to best determine which functions/defines have been modified between the two versions? Yes, the diff itself sometimes gives hints as to what has changed, but it's not always correct. Think about when it modifies the start of a function, but the diffstat "name" shows the previous function, a correct marking, but not what is needed.
Is the correct answer really going to be "compile the two versions and compare the AST" or something like that? No "diff library" somewhere that "knows" how to parse C (and Rust) that can do this in a faster way? Surely I'm missing something obvious here...
Replies (5)
-
@chinmay@social.treehouse.systems 2026-04-06 10:29
@wilfredh labelling hunks with function names should be possible to add to difftastic, no? @gregkh
-
@mei@donotsta.re 2026-04-06 10:38
@gregkh how much do you care about handling preprocessor weirdness correctly?
-
@zstg@fedia.social 2026-04-06 11:23
@gregkh this seems like something Magit can do 🤔
-
@jlhertel@fosstodon.org 2026-04-07 07:07
@gregkh maybe experiment with the different ways of generating diffs? The git diff sub-command has an option called algorithm, which defines how the diff is computed. If I remember correctly Myers is the default and its not that great. Histogram gave me the best results so far.
-
@neverpanic@chaos.social 2026-04-06 10:32
@gregkh @mxk that sounds like a problem that https://mergiraf.org/ must have already solved, maybe you can steal their code to do something similar? I don't think they have an API for that, though.