Repository: dandavison/delta
Pull request #454 (2020-12-21 06:32:20)

Bump git2 from 0.13.12 to 0.13.13
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.12 to 0.13.13.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/rust-lang/git2-rs/commit/1ff740daecd2698004e0ce6185d58e040d3c4343"><code>1ff740d</code></a> Bump git2 to 0.13.13</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/56bc2dc7e5751724fd98b008c1af44cc6dd430af"><code>56bc2dc</code></a> Bump libgit2-sys to 0.12.15+1.1.0</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/ebd15ad3610b40d08f342bc047cb4381938545b3"><code>ebd15ad</code></a> Fix minor typo s/deriviative/derivative/ in docs (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/644">#644</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/dd6d3643cca21c55d23cc5a0bd6e72244a0448f8"><code>dd6d364</code></a> Sync config docs (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/643">#643</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/3a85308cc7114515574a612de4dbe0ced9904ef8"><code>3a85308</code></a> Allow creating detached remotes (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/641">#641</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/e42d59569156f964980cdf7fa481b64e08e31732"><code>e42d595</code></a> Update libgit2 (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/642">#642</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/9a1e9062809764887f3de2393c3717bb46150eda"><code>9a1e906</code></a> Add rerun-if-changed to libgit2-sys build script. (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/640">#640</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/0313adc9624b19cbfe7a7c432831cdd467a925c4"><code>0313adc</code></a> Provide a binding for GIT_OPT_ENABLE_STRICT_OBJECT_CREATION (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/638">#638</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/2ba185289ca3ccb254396cf7b8f786d2be9a5172"><code>2ba1852</code></a> More Better Worktree Support (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/603">#603</a>)</li>
<li><a href="https://github.com/rust-lang/git2-rs/commit/7d755ae95f96157488e0f7c4aa33fba3fbe07579"><code>7d755ae</code></a> Fix &quot;bya&quot; -&gt; &quot;by a&quot; typo (<a href="https://github-redirect.dependabot.com/rust-lang/git2-rs/issues/634">#634</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/rust-lang/git2-rs/compare/0.13.12...0.13.13">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.12&new-version=0.13.13)](https://dependabot.com/compatibility-score/?dependency-name=git2&package-manager=cargo&previous-version=0.13.12&new-version=0.13.13)

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 1e1b6f8..0116523 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -364,9 +364,9 @@ dependencies = [
 
 [[package]]
 name = "git2"
-version = "0.13.12"
+version = "0.13.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224"
+checksum = "802b535f89475f22bb2b3d589de07861417e67b1a358c7ec8e5005bf4f209133"
 dependencies = [
  "bitflags",
  "libc",
@@ -457,9 +457,9 @@ checksum = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
 
 [[package]]
 name = "libgit2-sys"
-version = "0.12.14+1.1.0"
+version = "0.12.15+1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549"
+checksum = "48c39622f3887bc7fb2fff6d06293f64b02c1dfa281212566ac155171d13b0eb"
 dependencies = [
  "cc",
  "libc",
diff --git a/Cargo.toml b/Cargo.toml
index 237618d..dda0b8f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,7 @@ unicode-width = "0.1.8"
 vte = "0.9.0"
 
 [dependencies.git2]
-version = "0.13.12"
+version = "0.13.13"
 default-features = false
 features = []
 
diff --git a/src/cli.rs b/src/cli.rs
index 41483a9..22e3de2 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -365,7 +365,8 @@ pub struct Opt {
 
     #[structopt(long = "hunk-header-style", default_value = "syntax")]
     /// Style (foreground, background, attributes) for the hunk-header. See STYLES section. The
-    /// style 'omit' can be used to remove the hunk header section from the output.
+    /// special attribute 'file' can be used to include the file path in the hunk header. The style
+    /// 'omit' can be used to remove the hunk header section from the output.
     pub hunk_header_style: String,
 
     #[structopt(long = "hunk-header-decoration-style", default_value = "blue box")]
diff --git a/src/config.rs b/src/config.rs
index 28e571d..6d47ac5 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -32,6 +32,7 @@ pub struct Config {
     pub file_style: Style,
     pub git_config_entries: HashMap<String, GitConfigEntry>,
     pub hunk_header_style: Style,
+    pub hunk_header_style_include_file_path: bool,
     pub hyperlinks: bool,
     pub hyperlinks_file_link_format: String,
     pub inspect_raw_lines: cli::InspectRawLines,
@@ -163,6 +164,10 @@ impl From<cli::Opt> for Config {
             file_style,
             git_config_entries: opt.git_config_entries,
             hunk_header_style,
+            hunk_header_style_include_file_path: opt
+                .hunk_header_style
+                .split(' ')
+                .any(|s| s == "file"),
             hyperlinks: opt.hyperlinks,
             hyperlinks_file_link_format: opt.hyperlinks_file_link_format,
             inspect_raw_lines: opt.computed.inspect_raw_lines,
diff --git a/src/delta.rs b/src/delta.rs
index adcb40a..e401e26 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -1,4 +1,5 @@
 use std::borrow::Cow;
+use std::fmt::Write as FmtWrite;
 use std::io::BufRead;
 use std::io::Write;
 
@@ -485,6 +486,13 @@ fn handle_hunk_header_line(
             writeln!(painter.writer)?;
         }
         if !line.is_empty() {
+            if config.hunk_header_style_include_file_path {
+                let _ = write!(
+                    &mut painter.output_buffer,
+                    "{}: ",
+                    config.file_style.paint(plus_file)
+                );
+            };
             let lines = vec![(line, State::HunkHeader)];
             let syntax_style_sections = Painter::get_syntax_style_sections_for_lines(
                 &lines,
@@ -509,7 +517,7 @@ fn handle_hunk_header_line(
                 &painter.output_buffer,
                 &painter.output_buffer,
                 &config.decorations_width,
-                config.hunk_header_style,
+                config.null_style,
                 decoration_ansi_term_style,
             )?;
             painter.output_buffer.clear();
diff --git a/src/parse_style.rs b/src/parse_style.rs
index 565defa..1fa4fb0 100644
--- a/src/parse_style.rs
+++ b/src/parse_style.rs
@@ -241,6 +241,8 @@ fn parse_ansi_term_style(
             style.is_strikethrough = true;
         } else if word == "ul" || word == "underline" {
             style.is_underline = true;
+        } else if word == "file" {
+            // Allow: this is meaningful in hunk-header-style.
         } else if !seen_foreground {
             if word == "syntax" {
                 is_syntax_highlighted = true;


Test patch:
diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs
index f412158..72c4c5f 100644
--- a/src/tests/test_example_diffs.rs
+++ b/src/tests/test_example_diffs.rs
@@ -1008,6 +1008,27 @@ src/align.rs
         assert!(output.contains("@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"));
     }
 
+    #[test]
+    fn test_hunk_header_style_with_file() {
+        let config = integration_test_utils::make_config_from_args(&[
+            "--file-style",
+            "yellow",
+            "--hunk-header-style",
+            "file red",
+        ]);
+        let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
+
+        ansi_test_utils::assert_line_has_style(
+            &output,
+            11,
+            "src/align.rs: impl<'a> Alignment<'a> {",
+            "yellow",
+            &config,
+        );
+        let output = strip_ansi_codes(&output);
+        assert!(output.contains("src/align.rs: impl<'a> Alignment<'a> {"));
+    }
+
     #[test]
     fn test_commit_style_with_color_only_has_style() {
         let config = integration_test_utils::make_config_from_args(&[