Teach --dirstat not to completely ignore rearranged lines within a file
Currently, the --dirstat analysis ignores when lines within a file are rearranged, because the "damage" calculated by show_dirstat() is 0. However, if the object name has changed, we already know that there is some damage, and it is unintuitive to claim there is _no_ damage. Teach show_dirstat() to assign a minimum amount of damage (== 1) to entries for which the analysis otherwise yields zero damage, to still represent that these files are changed, instead of saying that there is no change. Also, skip --dirstat analysis when the object names are the same (e.g. for a pure file rename). Signed-off-by: Johan Herland <johan@herland.net> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0133dab75d
commit
2ff3a80334
@ -300,9 +300,7 @@ diff --no-index --name-status -- dir2 dir
|
||||
diff --no-index dir dir3
|
||||
diff master master^ side
|
||||
diff --dirstat master~1 master~2
|
||||
# --dirstat doesn't notice changes that simply rearrange existing lines
|
||||
diff --dirstat initial rearrange
|
||||
# ...but --dirstat-by-file does notice changes that only rearrange lines
|
||||
diff --dirstat-by-file initial rearrange
|
||||
EOF
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
$ git diff --dirstat initial rearrange
|
||||
100.0% dir/
|
||||
$
|
||||
|
Reference in New Issue
Block a user