Skip to content

diff: correct diff stat alignment in presence of renames w/ common prefix. - #7057

Merged
ethomson merged 3 commits into
libgit2:mainfrom
kivikakk:diff-stat-alignment
Jun 5, 2025
Merged

diff: correct diff stat alignment in presence of renames w/ common prefix.#7057
ethomson merged 3 commits into
libgit2:mainfrom
kivikakk:diff-stat-alignment

Conversation

@kivikakk

Copy link
Copy Markdown
Contributor

Hi old friends!

I noticed that libgit2's diff stat has its alignment get thrown out in the presence of renames where there's a common prefix, e.g.:

 lib/nos_web/controllers/user_controller.ex                                   | 7 ++++++-
 lib/nos_web/controllers/{page_html.ex => user_html.ex} | 8 ++-----
 lib/nos_web/controllers/user_html/show.html.heex                             | 3 +++-

This PR adds a test for this (fails on main), and then fixes it by reproducing the common prefix detection when calculating git_diff_stats's max_name member. That now fully accounts for the various formats (i.e. samename, oldname => newname, prefix{oldsuffix => newsuffix}).

This removed the sole use of renames in the same struct, so I dropped it.

@ethomson

ethomson commented Jun 5, 2025

Copy link
Copy Markdown
Member

Thanks for the fix!

@ethomson
ethomson merged commit d0da681 into libgit2:main Jun 5, 2025
@kivikakk

kivikakk commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

Thanks! :)

@kivikakk
kivikakk deleted the diff-stat-alignment branch June 5, 2025 13:02
@ethomson ethomson added the bug label Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants