summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-02-12 13:29:46 -0600
committerGitHub <noreply@github.com>2020-02-12 13:29:46 -0600
commitcd3226a8f6449ab76bb772d30d74f009a28e1cb0 (patch)
tree099ea779fe0131b52639ef74c05588d888981639
parent08d3b5db2d6332fc8080d095cf92184ae7e3ca00 (diff)
parentdad1aea90c27b7a74ee2c8f8eafab9d472756040 (diff)
Merge pull request #94 from dandavison/93-show-binary-file-diff-line
Show binary file diff line
-rw-r--r--src/delta.rs21
-rw-r--r--testing/93-binary.sh16
2 files changed, 37 insertions, 0 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 1425bf15..7f8aff5a 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -119,6 +119,7 @@ where
}
} else if source == Source::DiffUnified && line.starts_with("Only in ")
|| line.starts_with("Submodule ")
+ || line.starts_with("Binary files ")
{
// Additional FileMeta cases:
//
@@ -704,6 +705,13 @@ mod tests {
);
}
+ #[test]
+ fn test_binary_files_differ() {
+ let options = get_command_line_options();
+ let output = strip_ansi_codes(&run_delta(BINARY_FILES_DIFFER, &options)).to_string();
+ assert!(output.contains("Binary files /dev/null and b/foo differ\n"));
+ }
+
const ADDED_FILE_INPUT: &str = "\
commit d28dc1ac57e53432567ec5bf19ad49ff90f0f7a5
Author: Dan Davison <dandavison7@gmail.com>
@@ -848,4 +856,17 @@ index ba28bfd..0000000
--- id :: forall a. (p ∧ q) a a
--- id | IsTup <- isTup @a = id :×: id
";
+
+ const BINARY_FILES_DIFFER: &str = "
+commit ad023698217b086f1bef934be62b4523c95f64d9 (HEAD -> master)
+Author: Dan Davison <dandavison7@gmail.com>
+Date: Wed Feb 12 08:05:53 2020 -0600
+
+ .
+
+diff --git a/foo b/foo
+new file mode 100644
+index 0000000..b572921
+Binary files /dev/null and b/foo differ
+";
}
diff --git a/testing/93-binary.sh b/testing/93-binary.sh
new file mode 100644
index 00000000..447ccdf6
--- /dev/null
+++ b/testing/93-binary.sh
@@ -0,0 +1,16 @@
+# Test script written by @gibfahn in https://github.com/dandavison/delta/issues/93
+dir=/tmp/tst
+rm -fr $dir && mkdir -p $dir && cd $dir
+git init
+echo hello > bar
+git add bar && git commit -m "added text file bar"
+echo -n -e \\x48\\x00\\x49\\x00 > foo
+git add foo
+GIT_PAGER="delta --theme=TwoDark" git diff --staged
+GIT_PAGER=less git diff --staged
+git commit -m "added binary file foo"
+echo -n -e \\x49\\x00\\x48\\x00 > foo
+git add foo
+git commit -m "changed binary file foo"
+GIT_PAGER="delta --theme=TwoDark" git log -p
+GIT_PAGER=less git log -p