Skip to content

diff_stats: use git's formatting of renames with common directories#4830

Merged
ethomson merged 2 commits intolibgit2:masterfrom
pks-t:pks/diff-stats-rename-common
Oct 7, 2018
Merged

diff_stats: use git's formatting of renames with common directories#4830
ethomson merged 2 commits intolibgit2:masterfrom
pks-t:pks/diff-stats-rename-common

Conversation

@pks-t
Copy link
Copy Markdown
Member

@pks-t pks-t commented Oct 4, 2018

In cases where a file gets renamed such that the directories containing
it previous and after the rename have a common prefix, then git will
avoid printing this prefix twice and instead format the rename as
"prefix/{old => new}". We currently didn't do anything like that, but
simply printed "prefix/old -> prefix/new".

Adjust our behaviour to instead match upstream. Adjust the test for this
behaviour to expect the new format.


I recommend to go through both commits. The first one introduces just a test case, while the second one changes that test case to demonstrate how the commit changes the output format of diff stats.

Fixes #4826

pks-t added 2 commits October 4, 2018 11:24
Until now, we didn't have any tests that verified that our format for
renames in subdirectories is correct. While our current behaviour is no
different than for renames that do not happen with a common prefix
shared between old and new file name, we intend to change the format to
instead match the format that upstream git uses.

Add a test case for this to document our current behaviour and to show
how the next commit will change that format.
In cases where a file gets renamed such that the directories containing
it previous and after the rename have a common prefix, then git will
avoid printing this prefix twice and instead format the rename as
"prefix/{old => new}". We currently didn't do anything like that, but
simply printed "prefix/old -> prefix/new".

Adjust our behaviour to instead match upstream. Adjust the test for this
behaviour to expect the new format.
Copy link
Copy Markdown
Contributor

@tiennou tiennou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@ethomson ethomson merged commit 0cd976c into libgit2:master Oct 7, 2018
@ethomson
Copy link
Copy Markdown
Member

ethomson commented Oct 7, 2018

Thanks for doing this!

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.

Support renames in diffstat formatting

3 participants