summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-04-26 16:54:28 -0400
committerDan Davison <dandavison7@gmail.com>2020-04-26 18:33:27 -0400
commit4d95f8528b200d39dfdacecc4a6098a0404cc36c (patch)
tree89b1a4bc94b6b6a92cb57aaea53fe563b03449f6
parent7cdebd72140b6428125a71b2c56d082990243474 (diff)
Add failing test of empty commit / empty files #128
-rw-r--r--src/delta.rs19
-rwxr-xr-xtests/examples/128-empty-file15
2 files changed, 34 insertions, 0 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 69f6109b..848fb5ee 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -385,6 +385,13 @@ mod tests {
}
#[test]
+ fn test_added_empty_file() {
+ let options = get_command_line_options();
+ let output = strip_ansi_codes(&run_delta(ADDED_EMPTY_FILE, &options)).to_string();
+ assert!(output.contains("\nadded: file\n"));
+ }
+
+ #[test]
fn test_renamed_file() {
let options = get_command_line_options();
let output = strip_ansi_codes(&run_delta(RENAMED_FILE_INPUT, &options)).to_string();
@@ -822,6 +829,18 @@ added: a.py
pass
";
+ const ADDED_EMPTY_FILE: &str = "
+commit c0a18433cb6e0ca8f796bfae9e31d95b06b91597 (HEAD -> master)
+Author: Dan Davison <dandavison7@gmail.com>
+Date: Sun Apr 26 16:32:58 2020 -0400
+
+ Initial commit
+
+diff --git a/file b/file
+new file mode 100644
+index 0000000..e69de29
+";
+
const RENAMED_FILE_INPUT: &str = "\
commit 1281650789680f1009dfff2497d5ccfbe7b96526
Author: Dan Davison <dandavison7@gmail.com>
diff --git a/tests/examples/128-empty-file b/tests/examples/128-empty-file
new file mode 100755
index 00000000..a52bdb0c
--- /dev/null
+++ b/tests/examples/128-empty-file
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+
+repo=$(mktemp -d)
+cd $repo
+
+git init
+git commit --allow-empty -m "Initial commit"
+
+touch file
+
+git add file
+git commit -m "Initial commit"
+
+git show