Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix truncated diffstat with binary files #1253

Merged
merged 2 commits into from

2 participants

@afrepues

This pull request extends the regular expression of magit-wash-diffstat to support the lines showing changes in binary files. To make it easier on humans to grasp what the regular expression is doing, it is first split into multiple lines in a separate commit.

afrepues added some commits
@afrepues afrepues magit-wash-diffstat: split regex to make it easier on humans
This is just in preparation to make it longer.
7d0a107
@afrepues afrepues magit-wash-diffstat: support binary files
Binary files are displayed with "Bin XXX -> YYY bytes" instead of the
change count and graph. The numbers correspond to the old and new sizes
of the binary file, not lines added/removed, hence the capture groups
for these are left empty and this text left with no special faces.
4e49ebf
@tarsius tarsius merged commit c70acae into from
@tarsius
Owner

Thanks.

@tarsius tarsius added this to the 2.1.0 milestone
@afrepues afrepues deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. @afrepues

    magit-wash-diffstat: split regex to make it easier on humans

    afrepues authored
    This is just in preparation to make it longer.
  2. @afrepues

    magit-wash-diffstat: support binary files

    afrepues authored
    Binary files are displayed with "Bin XXX -> YYY bytes" instead of the
    change count and graph. The numbers correspond to the old and new sizes
    of the binary file, not lines added/removed, hence the capture groups
    for these are left empty and this text left with no special faces.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 magit.el
View
9 magit.el
@@ -4080,7 +4080,14 @@ Customize variable `magit-diff-refine-hunk' to change the default mode."
(defun magit-wash-diffstat ()
(when (looking-at
- "^ ?\\(.*\\)\\( +| +\\)\\([0-9]+\\) ?\\(\\+*\\)\\(-*\\)$")
+ (concat
+ "^ ?\\(.*\\)" ; file
+ "\\( +| +\\)" ; separator
+ "\\([0-9]+\\|Bin\\(?: +[0-9]+ -> [0-9]+ bytes\\)?$\\)" ; cnt
+ " ?"
+ "\\(\\+*\\)" ; add
+ "\\(-*\\)" ; del
+ "$"))
(magit-bind-match-strings (file sep cnt add del)
(delete-region (point) (1+ (line-end-position)))
(magit-with-section (section diffstat 'diffstat)
Something went wrong with that request. Please try again.