Repository: dandavison/delta
Pull request #318 (2020-09-09 06:30:13)

Bump git2 from 0.13.10 to 0.13.11
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.10 to 0.13.11.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/rust-lang/git2-rs/commits/0.13.11">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=git2&package-manager=cargo&previous-version=0.13.10&new-version=0.13.11)](https://dependabot.com/compatibility-score/?dependency-name=git2&package-manager=cargo&previous-version=0.13.10&new-version=0.13.11)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 6dd1d04..152dd7a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -306,7 +306,7 @@ dependencies = [
  "console 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "dirs 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "error-chain 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.13.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -320,12 +320,12 @@ dependencies = [
 
 [[package]]
 name = "git2"
-version = "0.13.10"
+version = "0.13.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.12.12+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.12.13+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -402,7 +402,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "libgit2-sys"
-version = "0.12.12+1.0.1"
+version = "0.12.13+1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1007,7 +1007,7 @@ dependencies = [
 "checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3"
 "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
 "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-"checksum git2 0.13.10 (registry+https://github.com/rust-lang/crates.io-index)" = "86d97249f21e9542caeee9f8e1d150905cd875bf723f5ff771bdb4852eb83a24"
+"checksum git2 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165"
 "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
 "checksum hermit-abi 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
 "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
@@ -1018,7 +1018,7 @@ dependencies = [
 "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
 "checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
-"checksum libgit2-sys 0.12.12+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0100ae90655025134424939f1f60e27e879460d451dff6afedde4f8226cbebfc"
+"checksum libgit2-sys 0.12.13+1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "069eea34f76ec15f2822ccf78fe0cdb8c9016764d0a12865278585a74dbdeae5"
 "checksum libz-sys 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af67924b8dd885cccea261866c8ce5b74d239d272e154053ff927dae839f5ae9"
 "checksum line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
 "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
diff --git a/Cargo.toml b/Cargo.toml
index 355a3f2..59ca0ed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,7 @@ unicode-width = "0.1.8"
 vte = "0.8.0"
 
 [dependencies.git2]
-version = "0.13.10"
+version = "0.13.11"
 default-features = false
 features = []
 
diff --git a/src/delta.rs b/src/delta.rs
index 9c411d8..0a8f151 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -380,9 +380,6 @@ fn handle_hunk_header_line(
     plus_file: &str,
     config: &Config,
 ) -> std::io::Result<()> {
-    if config.hunk_header_style.is_omitted {
-        return Ok(());
-    }
     let decoration_ansi_term_style;
     let draw_fn = match config.hunk_header_style.decoration_style {
         DecorationStyle::Box(style) => {
@@ -432,6 +429,8 @@ fn handle_hunk_header_line(
             config.hunk_header_style,
             decoration_ansi_term_style,
         )?;
+    } else if config.hunk_header_style.is_omitted {
+        writeln!(painter.writer)?;
     } else {
         let line = match painter.prepare(&raw_code_fragment, false) {
             s if s.len() > 0 => format!("{} ", s),
@@ -466,11 +465,10 @@ fn handle_hunk_header_line(
                 config.hunk_header_style,
                 decoration_ansi_term_style,
             )?;
-            if !config.hunk_header_style.is_raw {
-                painter.output_buffer.clear()
-            };
+            painter.output_buffer.clear();
         }
     };
+
     // Emit a single line number, or prepare for full line-numbering
     if config.line_numbers {
         painter
diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs
index 0ad5057..e03da5f 100644
--- a/src/features/line_numbers.rs
+++ b/src/features/line_numbers.rs
@@ -559,6 +559,21 @@ pub mod tests {
         assert_eq!(strip_ansi_codes(line_2), " 2  ⋮    │-b = 2");
     }
 
+    #[test]
+    fn test_hunk_header_style_is_omit() {
+        let config = make_config_from_args(&["--line-numbers", "--hunk-header-style", "omit"]);
+        let output = run_delta(TWO_LINE_DIFFS, &config);
+        let output = strip_ansi_codes(&output);
+        let mut lines = output.lines().skip(4);
+        assert_eq!(lines.next().unwrap(), " 1  ⋮ 1  │a = 1");
+        assert_eq!(lines.next().unwrap(), " 2  ⋮    │b = 2");
+        assert_eq!(lines.next().unwrap(), "    ⋮ 2  │bb = 2");
+        assert_eq!(lines.next().unwrap(), "");
+        assert_eq!(lines.next().unwrap(), "499 ⋮499 │a = 3");
+        assert_eq!(lines.next().unwrap(), "500 ⋮    │b = 4");
+        assert_eq!(lines.next().unwrap(), "    ⋮500 │bb = 4");
+    }
+
     pub const TWO_MINUS_LINES_DIFF: &str = "\
 diff --git i/a.py w/a.py
 index 223ca50..e69de29 100644
@@ -589,6 +604,21 @@ index 223ca50..367a6f6 100644
  a = 1
 -b = 2
 +bb = 2
+";
+
+    const TWO_LINE_DIFFS: &str = "\
+diff --git i/a.py w/a.py
+index 223ca50..367a6f6 100644
+--- i/a.py
++++ w/a.py
+@@ -1,2 +1,2 @@
+ a = 1
+-b = 2
++bb = 2
+@@ -499,2 +499,2 @@
+ a = 3
+-b = 4
++bb = 4
 ";
 
     const FIVE_DIGIT_LINE_NUMBER_DIFF: &str = "\
diff --git a/src/options/set.rs b/src/options/set.rs
index a6b4f15..a9ca6be 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -19,8 +19,8 @@ use crate::options::option_value::{OptionValue, ProvenancedOptionValue};
 use crate::options::{self, theme};
 
 macro_rules! set_options {
-	([$( $field_ident:ident ),* ],
-     $opt:expr, $builtin_features:expr, $git_config:expr, $arg_matches:expr, $expected_option_name_map:expr, $check_names:expr) => {
+    ([$( $field_ident:ident ),* ],
+    $opt:expr, $builtin_features:expr, $git_config:expr, $arg_matches:expr, $expected_option_name_map:expr, $check_names:expr) => {
         let mut option_names = HashSet::new();
         $(
             let kebab_case_field_name = stringify!($field_ident).replace("_", "-");
@@ -59,7 +59,7 @@ macro_rules! set_options {
                              &option_names - &expected_option_names));
             }
         }
-	}
+    }
 }
 
 pub fn set_options(
@@ -192,6 +192,10 @@ pub fn set_options(
     // there (does not emit lines in 1-1 correspondence with raw git output). See #274.
     if opt.color_only {
         opt.side_by_side = false;
+        opt.file_style = "raw".to_string();
+        opt.commit_style = "raw".to_string();
+        opt.hunk_header_style = "raw".to_string();
+        opt.hunk_header_decoration_style = "none".to_string();
     }
 }
 


Test patch:
diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs
index ba847c2..e7a00ee 100644
--- a/src/tests/test_example_diffs.rs
+++ b/src/tests/test_example_diffs.rs
@@ -819,11 +819,15 @@ src/align.rs
             "--line-numbers",
         ]);
         let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
-        assert!(output.contains("
-@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"));
-        assert!(!output.contains("
+        assert!(output.contains(
+            "
+@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"
+        ));
+        assert!(!output.contains(
+            "
 
-@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"));
+@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"
+        ));
         ansi_test_utils::assert_line_has_no_color(
             &output,
             9,
@@ -831,6 +835,50 @@ src/align.rs
         );
     }
 
+    #[test]
+    fn test_color_only_output_is_in_one_to_one_correspondence_with_input() {
+        _do_test_output_is_in_one_to_one_correspondence_with_input(&["--color-only", "true"]);
+        _do_test_output_is_in_one_to_one_correspondence_with_input(&[
+            "--color-only",
+            "true",
+            "--file-style",
+            "blue",
+            "--commit-style",
+            "omit",
+            "--hunk-header-style",
+            "omit",
+            "--hunk-header-decoration-style",
+            "omit",
+        ]);
+        _do_test_output_is_in_one_to_one_correspondence_with_input(&[
+            "--color-only",
+            "true",
+            "--file-style",
+            "blue",
+            "--commit-style",
+            "red",
+            "--hunk-header-style",
+            "syntax",
+            "--hunk-header-decoration-style",
+            "box",
+        ]);
+    }
+
+    fn _do_test_output_is_in_one_to_one_correspondence_with_input(args: &[&str]) {
+        let config = integration_test_utils::make_config_from_args(args);
+        let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
+
+        let output = strip_ansi_codes(&output);
+        let output_lines: Vec<&str> = output.split('\n').collect();
+        let input_lines: Vec<&str> = GIT_DIFF_SINGLE_HUNK.split('\n').collect();
+
+        assert_eq!(input_lines.len(), output_lines.len());
+
+        for n in 0..input_lines.len() {
+            assert_eq!(input_lines[n], output_lines[n]);
+        }
+    }
+
     #[test]
     fn test_hunk_header_style_colored_input_color_is_stripped_under_normal() {
         let config = integration_test_utils::make_config_from_args(&[