From 5cc4dc06e10c2f8ee6ab6d4f5fa1ee40a3a30aea Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Thu, 10 Nov 2016 14:36:53 -0500
Subject: [PATCH] check_whitespace: use a literal block for whitespace errors

We're dumping file content here, so to avoid spurious mentions and other
special things, quote it.
---
 src/hooks/check_whitespace.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/hooks/check_whitespace.rs b/src/hooks/check_whitespace.rs
index a19b486e..7094b735 100644
--- a/src/hooks/check_whitespace.rs
+++ b/src/hooks/check_whitespace.rs
@@ -37,7 +37,7 @@ impl Hook for CheckWhitespace {
             .arg(commit.sha1.as_str())
             .output());
         if !diff_tree.status.success() {
-            result.add_error(format!("commit {} adds bad whitespace:\n{}",
+            result.add_error(format!("commit {} adds bad whitespace:  \n```\n{}```",
                                      commit.sha1_short,
                                      String::from_utf8_lossy(&diff_tree.stdout)));
         }
@@ -68,7 +68,8 @@ mod tests {
         assert_eq!(result.alerts().len(), 0);
         assert_eq!(result.errors().len(), 1);
         assert_eq!(&result.errors()[0],
-                   "commit 829cdf8 adds bad whitespace:\n\
+                   "commit 829cdf8 adds bad whitespace:  \n\
+                    ```\n\
                     crlf-file:1: trailing whitespace.\n\
                     +This file contains CRLF lines.\r\n\
                     crlf-file:2: trailing whitespace.\n\
@@ -85,7 +86,8 @@ mod tests {
                     trailing-spaces:3: trailing whitespace.\n\
                     +trailing \n\
                     trailing-tab:3: trailing whitespace.\n\
-                    +trailing\t\n");
+                    +trailing\t\n\
+                    ```");
         assert_eq!(result.allowed(), false);
         assert_eq!(result.pass(), false);
     }
-- 
GitLab