1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-11 20:11:43 +00:00

Compare commits

...

24 Commits

Author SHA1 Message Date
Keith Hall b671e53c2c Merge pull request #3857 from MeGaurav4/master
feat: implement `-b` / `--number-nonblank` for `cat -b` compatibility
2026-08-11 17:39:20 +03:00
MeGaurav4 de2e651bf5 Merge remote-tracking branch 'origin/master' into pr-3857 2026-08-11 11:48:10 +05:30
MeGaurav4 061fb216cb feat: implement -b / --number-nonblank for cat -b compatibility
Adds a `-b` / `--number-nonblank` flag that numbers only non-blank
lines.  Blank lines (those containing only the line terminator) are
printed without a number and don't advance the counter, matching
`cat -b` behaviour.

- `-b` implies `--style=numbers` (same as `-n`), but only counts
  non-blank lines
- `-b` takes precedence over `-n`: both `-bn` and `-nb` behave like `-b`
- `-bp` disables numbering (plain mode wins)
- Works with files, stdin, and piped output (like `-n`)

Closes #3856.
2026-08-11 11:48:10 +05:30
Keith Hall af59a32183 Merge pull request #3876 from Matei02355/fix-log-syntax-performance-3866
fix(syntax): avoid repeated log level scans
2026-08-10 21:30:13 +03:00
Keith Hall c63838efeb Merge branch 'master' into fix-log-syntax-performance-3866 2026-08-10 21:19:46 +03:00
Matei6942 cecbb80093 fix(syntax): preserve log-level scopes in Syslog 2026-08-10 20:56:35 +03:00
Matei6942 3ca4a01be6 fix(syntax): use start-of-line anchor for log levels 2026-08-10 20:00:44 +03:00
Keith Hall 8112350da6 Merge pull request #3747 from mvanhorn/fix/3697-bat-auto-detect-language-from-stdin
chore: improve auto-detection of language from stdin via first-line patterns and add tests
2026-08-10 19:43:01 +03:00
Keith Hall a5deaf63ff Merge branch 'master' into fix/3697-bat-auto-detect-language-from-stdin 2026-08-10 19:32:11 +03:00
Keith Hall 2fb2415731 Merge pull request #3885 from latent-9/fix-doc-typos
Fix doubled word in README
2026-08-10 05:37:48 +03:00
latent-9 a58f23724a Fix doubled word in README 2026-08-09 18:05:20 +12:00
Matei6942 531d54b110 docs: add changelog entry for #3876 2026-08-02 10:52:39 +03:00
Matei6942 db69aab106 fix(syntax): avoid repeated log level scans 2026-08-02 10:52:05 +03:00
auto-merge-dependabot-prs[bot] 2ba8db9c14 Merge pull request #3874 from sharkdp/dependabot/cargo/minus-5.7.2
build(deps): bump minus from 5.7.1 to 5.7.2
2026-08-01 04:01:25 +00:00
dependabot[bot] d344844486 build(deps): bump minus from 5.7.1 to 5.7.2
Bumps [minus](https://github.com/AMythicDev/minus) from 5.7.1 to 5.7.2.
- [Changelog](https://github.com/AMythicDev/minus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/AMythicDev/minus/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: minus
  dependency-version: 5.7.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 03:50:26 +00:00
auto-merge-dependabot-prs[bot] aeb0e4c457 Merge pull request #3869 from sharkdp/dependabot/cargo/gix-0.86.0
build(deps): bump gix from 0.85.0 to 0.86.0
2026-08-01 03:47:33 +00:00
dependabot[bot] 1cf12d49bd build(deps): bump gix from 0.85.0 to 0.86.0
Bumps [gix](https://github.com/GitoxideLabs/gitoxide) from 0.85.0 to 0.86.0.
- [Release notes](https://github.com/GitoxideLabs/gitoxide/releases)
- [Changelog](https://github.com/GitoxideLabs/gitoxide/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GitoxideLabs/gitoxide/compare/gix-v0.85.0...gix-v0.86.0)

---
updated-dependencies:
- dependency-name: gix
  dependency-version: 0.86.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 03:33:08 +00:00
auto-merge-dependabot-prs[bot] 7cb212646c Merge pull request #3871 from sharkdp/dependabot/cargo/terminal-colorsaurus-1.0.3
build(deps): bump terminal-colorsaurus from 1.0.0 to 1.0.3
2026-08-01 03:28:34 +00:00
dependabot[bot] 6573ca9307 build(deps): bump terminal-colorsaurus from 1.0.0 to 1.0.3
Bumps [terminal-colorsaurus](https://github.com/tautropfli/terminal-colorsaurus) from 1.0.0 to 1.0.3.
- [Release notes](https://github.com/tautropfli/terminal-colorsaurus/releases)
- [Changelog](https://github.com/tautropfli/terminal-colorsaurus/blob/main/changelog.md)
- [Commits](https://github.com/tautropfli/terminal-colorsaurus/compare/1.0.0...1.0.3)

---
updated-dependencies:
- dependency-name: terminal-colorsaurus
  dependency-version: 1.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 03:09:37 +00:00
auto-merge-dependabot-prs[bot] f04dc80bc7 Merge pull request #3873 from sharkdp/dependabot/cargo/execute-0.3.0
build(deps): bump execute from 0.2.15 to 0.3.0
2026-08-01 03:06:47 +00:00
dependabot[bot] e6ac6ce08d build(deps): bump execute from 0.2.15 to 0.3.0
Bumps [execute](https://github.com/magiclen/execute) from 0.2.15 to 0.3.0.
- [Commits](https://github.com/magiclen/execute/compare/v0.2.15...v0.3.0)

---
updated-dependencies:
- dependency-name: execute
  dependency-version: 0.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 02:38:14 +00:00
auto-merge-dependabot-prs[bot] 949f18e23a Merge pull request #3868 from sharkdp/dependabot/cargo/proc-macro2-1.0.107
build(deps): bump proc-macro2 from 1.0.106 to 1.0.107
2026-08-01 02:19:43 +00:00
dependabot[bot] 969b33dad1 build(deps): bump proc-macro2 from 1.0.106 to 1.0.107
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.106 to 1.0.107.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.106...1.0.107)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-version: 1.0.107
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 02:03:54 +00:00
Matt Van Horn 530e83a455 feat: bat auto-detects language from stdin via first-line patterns
When piped input has no filename hint, bat falls back to plain text. Many
common formats can be reliably identified by shebang or magic-string in the
first line (#!/bin/bash, <?xml, {"json: ...}, etc.). Adds a first-line
pattern matcher to assets.rs.

Fixes #3697
2026-05-16 13:51:00 -07:00
16 changed files with 509 additions and 192 deletions
+2
View File
@@ -9,6 +9,7 @@
## Features ## Features
- Add `-b` / `--number-nonblank` flag to only number non-blank lines, for `cat -b` compatibility. Closes #3856, see #3857 (@MeGaurav4)
- Add a `--sanitize=<auto|always|never>` flag for safe display of untrusted input. It implies `--strip-ansi` at the same value and additionally substitutes terminal-active control bytes (cursor moves, charset switches, beep, etc.) and Unicode bidi / zero-width formatting characters with the Unicode replacement character (U+FFFD). Mitigates Trojan-Source-style spoofing (CVE-2021-42574). See #3729 (@curious-rabbit) - Add a `--sanitize=<auto|always|never>` flag for safe display of untrusted input. It implies `--strip-ansi` at the same value and additionally substitutes terminal-active control bytes (cursor moves, charset switches, beep, etc.) and Unicode bidi / zero-width formatting characters with the Unicode replacement character (U+FFFD). Mitigates Trojan-Source-style spoofing (CVE-2021-42574). See #3729 (@curious-rabbit)
- Map justfile, Justfile, .justfile, and *.justfile to Makefile syntax highlighting, see #3623 (@zachvalenta) - Map justfile, Justfile, .justfile, and *.justfile to Makefile syntax highlighting, see #3623 (@zachvalenta)
- Preserve `--diff` change markers and snip separators when `--plain` is set. Closes #3630, see #3643 (@mvanhorn) - Preserve `--diff` change markers and snip separators when `--plain` is set. Closes #3630, see #3643 (@mvanhorn)
@@ -24,6 +25,7 @@
- Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres) - Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres)
## Bugfixes ## Bugfixes
- Avoid repeated scans of long lines in Log syntax highlighting, see #3876 (@Matei02355)
- Fix `--list-languages` respecting `--paging=never`, see #3828 (@cyphercodes) - Fix `--list-languages` respecting `--paging=never`, see #3828 (@cyphercodes)
- Fix `--sanitize` passing through the bidi control characters U+200E, U+200F and U+061C, see #3862 (@lenamonj) - Fix `--sanitize` passing through the bidi control characters U+200E, U+200F and U+061C, see #3862 (@lenamonj)
- `--strip-ansi`: also strip 8-bit C1 introducers (U+0090, U+0098, U+009B, U+009D, U+009E, U+009F) and DCS/SOS/PM/APC sequence bodies, which previously passed through. See #3729 (@curious-rabbit) - `--strip-ansi`: also strip 8-bit C1 introducers (U+0090, U+0098, U+009B, U+009D, U+009E, U+009F) and DCS/SOS/PM/APC sequence bodies, which previously passed through. See #3729 (@curious-rabbit)
Generated
+162 -176
View File
@@ -68,7 +68,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -79,7 +79,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"once_cell_polyfill", "once_cell_polyfill",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -188,6 +188,21 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bisync"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5020822f6d6f23196ccaf55e228db36f9de1cf788052b37992e17cbc96ec41a7"
dependencies = [
"bisync_macros",
]
[[package]]
name = "bisync_macros"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d21f40d350a700f6aa107e45fb26448cf489d34794b2ba4522181dc9f1173af6"
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.8.0" version = "0.8.0"
@@ -221,7 +236,7 @@ version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [ dependencies = [
"generic-array 0.14.7", "generic-array",
] ]
[[package]] [[package]]
@@ -354,7 +369,7 @@ dependencies = [
"encode_unicode", "encode_unicode",
"libc", "libc",
"unicode-width", "unicode-width",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -466,7 +481,7 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [ dependencies = [
"generic-array 0.14.7", "generic-array",
"typenum", "typenum",
] ]
@@ -519,9 +534,9 @@ dependencies = [
[[package]] [[package]]
name = "dashmap" name = "dashmap"
version = "6.1.0" version = "6.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
@@ -665,7 +680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -675,34 +690,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de48cc4d1c1d97a20fd819def54b890cadde72ed3ad0c614822a0a433361be96" checksum = "de48cc4d1c1d97a20fd819def54b890cadde72ed3ad0c614822a0a433361be96"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
name = "execute" name = "execute"
version = "0.2.15" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0be3cc61fe54b4cae4463cdbda0401978ffe19d4dcc7a5201a312cddf64726dd" checksum = "a8bc8fa7331f8c9f97fb52c60c4e1d07fd424db18130cb252b1da7c6bbcfc2c9"
dependencies = [ dependencies = [
"execute-command-macro", "execute-command-macro",
"execute-command-tokens", "execute-command-tokens",
"generic-array 1.4.1",
] ]
[[package]] [[package]]
name = "execute-command-macro" name = "execute-command-macro"
version = "0.1.11" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3e748391d89b43c52decaed8645b4a83a09d14f5ee868071c6813389e9e7036" checksum = "889365b82d31077b07ed81c1b37f49eed80266f57c99bc3706e8d8d4783388ac"
dependencies = [ dependencies = [
"execute-command-macro-impl", "execute-command-macro-impl",
] ]
[[package]] [[package]]
name = "execute-command-macro-impl" name = "execute-command-macro-impl"
version = "0.1.12" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57dd896da3fbb77138059b015c013459d96063c66bcdd3b9094ff2e9d3f19a47" checksum = "581bbece7790a10aa1c40586be3be5b6f466f0a608386885a81924df372fd530"
dependencies = [ dependencies = [
"execute-command-tokens", "execute-command-tokens",
"quote", "quote",
@@ -711,9 +725,9 @@ dependencies = [
[[package]] [[package]]
name = "execute-command-tokens" name = "execute-command-tokens"
version = "0.1.9" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "729eda2ea2f6c5ef85150c85a9b2ce0a8e01f040e59cdb32521eaa6c840c9d51" checksum = "9ef469ea74199a1c75f76f5176e18e4a8864caa6b7ca528c97a5f5fe67c94902"
[[package]] [[package]]
name = "expect-test" name = "expect-test"
@@ -815,16 +829,6 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "generic-array"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dab9e9188e97a93276e1fe7b56401b851e2b45a46d045ca658100c1303ada649"
dependencies = [
"rustversion",
"typenum",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.4.2" version = "0.4.2"
@@ -860,9 +864,9 @@ dependencies = [
[[package]] [[package]]
name = "gix" name = "gix"
version = "0.85.0" version = "0.86.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa8b2e38ebfc4484dfef8580ddcaf8abb7285e6f3eb6413ff6775d104ae96ca6" checksum = "bb3790fd8981cba7949f1ba924ef865d902df731627bc5998d14164063892fce"
dependencies = [ dependencies = [
"gix-actor", "gix-actor",
"gix-attributes", "gix-attributes",
@@ -903,6 +907,7 @@ dependencies = [
"gix-validate", "gix-validate",
"gix-worktree", "gix-worktree",
"gix-worktree-stream", "gix-worktree-stream",
"gix-zlib",
"nonempty", "nonempty",
"smallvec", "smallvec",
"thiserror", "thiserror",
@@ -910,9 +915,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-actor" name = "gix-actor"
version = "0.41.1" version = "0.41.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bc998b8f746dda8565450d08a63b792ced9165d8c27a1ed3f02799ec6a7820f" checksum = "33f9308ad6fd35b2a865cbe4117ac61b2be59e4a9ef1621c7a9794f7c8e52c5b"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-date", "gix-date",
@@ -921,16 +926,16 @@ dependencies = [
[[package]] [[package]]
name = "gix-attributes" name = "gix-attributes"
version = "0.33.2" version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39b40888d0ed415c0744a6cdc61eebf0304c9d26ab726725b718443c322e5ba4" checksum = "c31c593692ebdc1e38858d9a2b56f6a594c501e24a38971fe6685571f5a07be0"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-features",
"gix-glob", "gix-glob",
"gix-path", "gix-path",
"gix-quote", "gix-quote",
"gix-trace", "gix-trace",
"kstring",
"smallvec", "smallvec",
"thiserror", "thiserror",
"unicode-bom", "unicode-bom",
@@ -938,18 +943,18 @@ dependencies = [
[[package]] [[package]]
name = "gix-bitmap" name = "gix-bitmap"
version = "0.3.2" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ebef0c26ad305747649e727bbcd56a7b7910754eb7cea88f6dff6f93c51283" checksum = "7cd1d118d0f5d88b96e6f6e13b566475fef4797ead4a02c26fed36c1375066f7"
dependencies = [ dependencies = [
"gix-error", "gix-error",
] ]
[[package]] [[package]]
name = "gix-chunk" name = "gix-chunk"
version = "0.7.2" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9faee47943b638e58ddd5e275a4906ad3e4b6c8584f1d41bd18ab9032ec52afb" checksum = "b2a871e5cab12ba568845714473505deefffb3c04eb47f4708ce344cd459c1cc"
dependencies = [ dependencies = [
"gix-error", "gix-error",
] ]
@@ -969,9 +974,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-commitgraph" name = "gix-commitgraph"
version = "0.37.1" version = "0.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f675d0df484a7f6a47e64bd6f311af489d947c0323b0564f36d14f3d7762abb" checksum = "a2cd7f054ae2727223fe46dd39c012f066b12f532962d336d29ee193261787da"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-chunk", "gix-chunk",
@@ -983,9 +988,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-config" name = "gix-config"
version = "0.58.0" version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a29bf266c4cdaf759e535c24ad4ce655b987aeb6911075643403cc7cc5ade583" checksum = "103d11bef95c467577ecfa8b7b86a22e65af3507b2c9bfa3809a4afbae7df301"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-config-value", "gix-config-value",
@@ -994,6 +999,7 @@ dependencies = [
"gix-path", "gix-path",
"gix-ref", "gix-ref",
"gix-sec", "gix-sec",
"gix-utils",
"smallvec", "smallvec",
"thiserror", "thiserror",
"unicode-bom", "unicode-bom",
@@ -1001,9 +1007,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-config-value" name = "gix-config-value"
version = "0.18.1" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed42168329552f6c2e5df09665c104199d45d84bedb53683738a49b57fe1baab" checksum = "9f813e312a3f7f327187823cd4c754a3e4d948c98907d11e8f37554a2b6b8059"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"bstr", "bstr",
@@ -1014,9 +1020,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-date" name = "gix-date"
version = "0.15.5" version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d63f9e28b59ddeb1a1eb9e5cf986a9222b5d484947445edbc20473939cc7fd0" checksum = "7e47b9e8cdc688296609b706428de570f88b1e0eed7156dde7b4a89d26fa4567"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-error", "gix-error",
@@ -1026,9 +1032,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-diff" name = "gix-diff"
version = "0.65.0" version = "0.66.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92c6d56c94edf92d78203a1cd416f770e35e10b6955ede6b9d7d0c22ff88a5f3" checksum = "fee7d89a3c507491cdfc57a1d1e0e300214720b4f7709ebc253e422f99822bfc"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-command", "gix-command",
@@ -1047,9 +1053,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-discover" name = "gix-discover"
version = "0.53.0" version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d624d5b23b10c1d85337645227abe353ac95ab8ff66a7bdd5ce689b2db33a722" checksum = "b9f517766fa1101dfe2606c1a19a8ffa699099030995a9194445446dfe261bdf"
dependencies = [ dependencies = [
"bstr", "bstr",
"dunce", "dunce",
@@ -1062,37 +1068,37 @@ dependencies = [
[[package]] [[package]]
name = "gix-error" name = "gix-error"
version = "0.2.4" version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e57831e199be480af90dcd7e459abed8a174c09ec9a6e2cc8f7ca6c54598b06b" checksum = "4a9292309fd944e71b2a3c96d3c03a6feb8852db646febdde7cbb9f79cb5f329"
dependencies = [ dependencies = [
"bstr", "bstr",
] ]
[[package]] [[package]]
name = "gix-features" name = "gix-features"
version = "0.48.1" version = "0.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1849ae154d38bc403185be14fa871e38e3c93ee606875d94e207fdb9fba52dbc" checksum = "20aa09e83a48dc02c5f5f08578aa79d3ab1bab4618b8c362f88684645a02bdcc"
dependencies = [ dependencies = [
"bytes", "bytes",
"crc32fast", "crc32fast",
"crossbeam-channel",
"gix-path", "gix-path",
"gix-trace", "gix-trace",
"gix-utils", "gix-utils",
"libc", "libc",
"once_cell", "once_cell",
"parking_lot",
"prodash", "prodash",
"thiserror",
"walkdir", "walkdir",
"zlib-rs",
] ]
[[package]] [[package]]
name = "gix-filter" name = "gix-filter"
version = "0.32.0" version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6644fb2ef97928c278675b239f366b457103d7e436f811d27331a8daf212759c" checksum = "5e7b5dbf524d97e839f642930c76d7f011c0791e7d11d8148989ac5af7c76aa8"
dependencies = [ dependencies = [
"bstr", "bstr",
"encoding_rs", "encoding_rs",
@@ -1111,12 +1117,11 @@ dependencies = [
[[package]] [[package]]
name = "gix-fs" name = "gix-fs"
version = "0.21.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cdff46db8798e47e2f727d84b9379aac5add3dd3d9d0b07bb4d7d5d640771fe" checksum = "865cf13fcaf5455220546cb9607c416bd1be9a6caafd143655a362fdeab64e80"
dependencies = [ dependencies = [
"bstr", "bstr",
"fastrand",
"gix-features", "gix-features",
"gix-path", "gix-path",
"gix-utils", "gix-utils",
@@ -1125,9 +1130,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-glob" name = "gix-glob"
version = "0.26.1" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1fcb8ef5b16bcf874abe9b68d8abb3c0493c876d367ab824151f30a0f3f3756" checksum = "421e92a711554fa5827d1b0599d3389acdd0f6729e97a8c5a57d79af1e50bf36"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"bstr", "bstr",
@@ -1137,9 +1142,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-hash" name = "gix-hash"
version = "0.25.1" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0926d3819c837750b4e03c7754901e73f68b8c9b690753a6372a1bed4eedce" checksum = "13adaa73415fd6c902310923f68d0b98e8cecf14b33ea58c02cc387cee56f54e"
dependencies = [ dependencies = [
"faster-hex", "faster-hex",
"gix-features", "gix-features",
@@ -1149,9 +1154,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-hashtable" name = "gix-hashtable"
version = "0.15.2" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e261d54091f0d1c729bc83f54548c071bdec60a697de1e58e88bdfd7a99d24e" checksum = "78fccd6fea3bcf0b39c076bae60ae49b08daaf538b950202101a981f9d3c01d3"
dependencies = [ dependencies = [
"gix-hash", "gix-hash",
"hashbrown 0.17.1", "hashbrown 0.17.1",
@@ -1160,9 +1165,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-ignore" name = "gix-ignore"
version = "0.21.1" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d491bab9bf2c9f341dc754f425c31d5d3f63aca615312167b82e1deeaca97d8d" checksum = "12cff8e8aa125e39377456073e63df3334d9e5741372ddcc226198015076dda2"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-glob", "gix-glob",
@@ -1173,9 +1178,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-imara-diff" name = "gix-imara-diff"
version = "0.2.3" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b305d85504de270ad3525d726a6b69cc59ee7b2269b014387651107ab9f0755b" checksum = "1a791e6620676a875f362f3156ed213e73ca099a09bf992c18812abe65cc37b1"
dependencies = [ dependencies = [
"bstr", "bstr",
"hashbrown 0.17.1", "hashbrown 0.17.1",
@@ -1183,9 +1188,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-index" name = "gix-index"
version = "0.53.0" version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36d45f82ec5a4d7542ea595e9ad16e03e26c8cb4f221e5bc9fcdcf469f63a681" checksum = "5009c4e7e9f9b4cfaaab1153e49133eb04d79c015b5702d6c3d2ab94271a89c6"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"bstr", "bstr",
@@ -1211,9 +1216,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-lock" name = "gix-lock"
version = "23.0.0" version = "24.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09b3bc074e5723027b482dcd9ab99d95804a53742f6de812d0172fbba4a186c1" checksum = "d4c69157820343bf1c6e4b88b9808e920900de02e18aaf5862b30ada43814848"
dependencies = [ dependencies = [
"gix-tempfile", "gix-tempfile",
"gix-utils", "gix-utils",
@@ -1222,9 +1227,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-object" name = "gix-object"
version = "0.62.0" version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "019b38afc3eac1e41f9fe09a327664b313ba4a120fa5f40e3678795d0e42783e" checksum = "0e48c235e7f886eb819fc878af75be889333dd3c38bee02ed7af48ae2cf596c4"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-actor", "gix-actor",
@@ -1241,9 +1246,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-odb" name = "gix-odb"
version = "0.82.0" version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fadc59f6fa0f9dd445eceee61060a2b59ca557f48da9fc677f567db535b782a" checksum = "8dd494ffb5037e62b8220109e894d2861ff2150a2cacbfccdba57ae1ebab2b96"
dependencies = [ dependencies = [
"arc-swap", "arc-swap",
"gix-features", "gix-features",
@@ -1254,6 +1259,7 @@ dependencies = [
"gix-pack", "gix-pack",
"gix-path", "gix-path",
"gix-quote", "gix-quote",
"gix-zlib",
"memmap2", "memmap2",
"parking_lot", "parking_lot",
"tempfile", "tempfile",
@@ -1262,9 +1268,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-pack" name = "gix-pack"
version = "0.72.0" version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3e7f1726cd2c0cd1cf1fc20be8a8e623f0b163f1f8d6fc836cfb9bc8cd758b" checksum = "6d5446127b269706e85998065267ddd2ccc3550179da6780b22fe496175ccb20"
dependencies = [ dependencies = [
"clru", "clru",
"gix-chunk", "gix-chunk",
@@ -1274,6 +1280,7 @@ dependencies = [
"gix-hashtable", "gix-hashtable",
"gix-object", "gix-object",
"gix-path", "gix-path",
"gix-zlib",
"memmap2", "memmap2",
"smallvec", "smallvec",
"thiserror", "thiserror",
@@ -1281,9 +1288,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-packetline" name = "gix-packetline"
version = "0.21.5" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b217dd0ee0c4021ecf169a4a519b1b4f80d15e3f3765f3dc466223dc0ac891d7" checksum = "3766025c72319c4accdd854a18e6f0dd176c8eb0f3bc8a60a7765be2b50cabf2"
dependencies = [ dependencies = [
"bstr", "bstr",
"faster-hex", "faster-hex",
@@ -1293,9 +1300,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-path" name = "gix-path"
version = "0.12.1" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afa6ac14cd14939ea94a496ce7460daa6511c09f5b84757e9cfc6f9c8d0f93a6" checksum = "1ed3e8d7a82e886e17a72e03d4ba0c13db6f2219b6cd4e2900b4cae426ec20c9"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-trace", "gix-trace",
@@ -1305,9 +1312,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-pathspec" name = "gix-pathspec"
version = "0.18.1" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3050783b41ee11511e1e8fb35623df81806194f4030395f14f48ea37c2798c9f" checksum = "49f6fa5f8007f008187c3f60b4373209ca83d1cc947f35ede03e16cd15a4d137"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"bstr", "bstr",
@@ -1320,10 +1327,11 @@ dependencies = [
[[package]] [[package]]
name = "gix-protocol" name = "gix-protocol"
version = "0.63.0" version = "0.64.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978468bae4ea2df20c72db3b20d0bdb548a0c1090b85a83643b553e6e0e041f2" checksum = "dede40e89c1e90f548415f50636bb051f6d9c60f68b8b710bc07825722d19588"
dependencies = [ dependencies = [
"bisync",
"bstr", "bstr",
"gix-date", "gix-date",
"gix-features", "gix-features",
@@ -1332,7 +1340,6 @@ dependencies = [
"gix-shallow", "gix-shallow",
"gix-transport", "gix-transport",
"gix-utils", "gix-utils",
"maybe-async",
"nonempty", "nonempty",
"thiserror", "thiserror",
] ]
@@ -1350,9 +1357,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-ref" name = "gix-ref"
version = "0.65.0" version = "0.66.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bbfbce1dfd7d7f8469ddef6d3518376aff664348f153cbe0fc3e58ef993d24e" checksum = "eeb0c90a8f6202ceaaa22996cbf837c943ccb2d8af9ff3490f0758305e6b7883"
dependencies = [ dependencies = [
"gix-actor", "gix-actor",
"gix-features", "gix-features",
@@ -1370,9 +1377,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-refspec" name = "gix-refspec"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bc36a4fb1a1540b59cf2da498783080743fa274b02a3f19ca444fc4015a9d4f" checksum = "7406282cc0259b51f6aee299ca3d31279a020530363152a2e6c96e8a7f7bbc83"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-error", "gix-error",
@@ -1386,9 +1393,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-revision" name = "gix-revision"
version = "0.47.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "885075c3c21eb9c06e0be3b3728ba5932c04e1c1011dcee7c81801980e3e986f" checksum = "e55e09d4a1ecf2beecc8c09cafcad37979e805b31f588b0e957e191df5783681"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-commitgraph", "gix-commitgraph",
@@ -1402,9 +1409,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-revwalk" name = "gix-revwalk"
version = "0.33.0" version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f11fe7ca2585193d3d70bbe0be175a2008d883a704cc7a55e454e113e689455" checksum = "36c113c0a53294dc6280ffc06cbcc4f50f820397e97d6a00b429a44b8db26e29"
dependencies = [ dependencies = [
"gix-commitgraph", "gix-commitgraph",
"gix-date", "gix-date",
@@ -1418,21 +1425,21 @@ dependencies = [
[[package]] [[package]]
name = "gix-sec" name = "gix-sec"
version = "0.14.1" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab8519976e4c7e486270740a5400369f37940779b80bd1377d94cfa1125d01b3" checksum = "af4fe6c152c1d50aea36f299825702cd37e303307832fec1d0fdd5844e47ce2f"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"gix-path", "gix-path",
"libc", "libc",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
name = "gix-shallow" name = "gix-shallow"
version = "0.12.1" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a292fc2fe548c5dfa575479d16b445b0ddf1dd2f56f1fec6aed386f82553cd97" checksum = "1ecc9f4b40537043e4bbd7d3d1760e74fb8e7b07a546166b558acaa73ad97f4a"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-hash", "gix-hash",
@@ -1443,9 +1450,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-submodule" name = "gix-submodule"
version = "0.32.0" version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7f9f594f7cbda0b38ba6b633b3e9a7b7901acdc5d27bc186a16633800cd1ac8" checksum = "5fd98077a56d08886112e6b08dc94076d03539f4bc0b9d7880e4be2b8a640d8c"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-config", "gix-config",
@@ -1458,11 +1465,11 @@ dependencies = [
[[package]] [[package]]
name = "gix-tempfile" name = "gix-tempfile"
version = "23.0.0" version = "24.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "691ea1e31435c7e7d4d04705ec9d1c0d9482c46b2acf512bc723939d8f0af7fb" checksum = "b675b920bd5a61d17ad542772f03ec34c60feb8ff683e1560c03ae967363731e"
dependencies = [ dependencies = [
"dashmap 6.1.0", "dashmap 6.2.1",
"gix-fs", "gix-fs",
"libc", "libc",
"parking_lot", "parking_lot",
@@ -1471,20 +1478,21 @@ dependencies = [
[[package]] [[package]]
name = "gix-trace" name = "gix-trace"
version = "0.1.20" version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44dc45eae785c0eb14173e0f152e6e224dcf4d45b6a6999a3aed22af541ad678" checksum = "be3eb81d9dc914335923e50d52829c551feefd6a72d176c4130c546b67a60814"
[[package]] [[package]]
name = "gix-transport" name = "gix-transport"
version = "0.57.2" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "186874f7ad1fb2f9a2f2aa9c2dabc7f9dd087bef74c1a0eee2b4a9cf0248fcb3" checksum = "b7c1bcf30081eb8ab04540a5795c67a2fcb22cb2e976e8b1a4ea657b1ed61469"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-command", "gix-command",
"gix-features", "gix-features",
"gix-packetline", "gix-packetline",
"gix-path",
"gix-quote", "gix-quote",
"gix-sec", "gix-sec",
"gix-url", "gix-url",
@@ -1493,9 +1501,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-traverse" name = "gix-traverse"
version = "0.59.0" version = "0.60.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5062cca8f2977565bbaf666ec31dbdb9bc9d9293beb65f9bec52e6c1121b62a1" checksum = "008c5cd879e46e86b5c2469e633611978b18775d53d05668d691bc13088bd409"
dependencies = [ dependencies = [
"bitflags 2.11.1", "bitflags 2.11.1",
"gix-commitgraph", "gix-commitgraph",
@@ -1510,40 +1518,43 @@ dependencies = [
[[package]] [[package]]
name = "gix-url" name = "gix-url"
version = "0.36.1" version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65bb01ec69d55e82ccb7a19e264501ead4e6aac38463a8cebfdd81e22bb67ab2" checksum = "42d10e53b8eae21ee601687f47bbbd6cb2ed7162cb4c1cafdd422fb7ec64cbee"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-path", "gix-path",
"gix-utils",
"percent-encoding", "percent-encoding",
"thiserror", "thiserror",
] ]
[[package]] [[package]]
name = "gix-utils" name = "gix-utils"
version = "0.3.3" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66c50966184123caf580ffa64e28031a878597f1c7fceb8fe19566c38eb1b771" checksum = "b1795bd2a970ca8b2185318c2abb97d955c71992f1cf28de73ad3b593a9f3ce8"
dependencies = [ dependencies = [
"bstr",
"fastrand", "fastrand",
"getrandom",
"unicode-normalization", "unicode-normalization",
] ]
[[package]] [[package]]
name = "gix-validate" name = "gix-validate"
version = "0.11.2" version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bc6fc771c4063ba7cd2f47b91fb6076251c6a823b64b7fe7b8874b0fe4afae3" checksum = "9a034e84d1e04e1b1f20f51f12491da230b6ac8b925d0c8e1b89bcd87a7c5ccc"
dependencies = [ dependencies = [
"bstr", "bstr",
] ]
[[package]] [[package]]
name = "gix-worktree" name = "gix-worktree"
version = "0.54.0" version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92399ed66f259592050c6ed9dc80105e095a2f8e87e6b83d98aa2e21d8e27036" checksum = "31eb8e675122e83585e461fe28f68ff8c5ed55b49017b697e7e76423ff973424"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-attributes", "gix-attributes",
@@ -1559,9 +1570,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-worktree-stream" name = "gix-worktree-stream"
version = "0.34.0" version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55f3a878c89a05470ad98c644b0015777c530da24854dd29e41fe4f41176840f" checksum = "3b088c8724e7be120c4798dd86925cf05332c9d356a463542578600c50c7a549"
dependencies = [ dependencies = [
"gix-attributes", "gix-attributes",
"gix-error", "gix-error",
@@ -1575,6 +1586,16 @@ dependencies = [
"parking_lot", "parking_lot",
] ]
[[package]]
name = "gix-zlib"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e8813f5579b3075ff9c90f7c59cd2b62b4ebb639361f0911648b22d7446cc7c"
dependencies = [
"thiserror",
"zlib-rs",
]
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.3" version = "0.3.3"
@@ -1757,15 +1778,6 @@ dependencies = [
"jiff-tzdb", "jiff-tzdb",
] ]
[[package]]
name = "kstring"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1"
dependencies = [
"static_assertions",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.5.0" version = "1.5.0"
@@ -1817,17 +1829,6 @@ version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "maybe-async"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "746873a384ad60adc5db74471dfaba74bd278afbdcfd81db93fafcdfc8b5ca0c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.8.0" version = "2.8.0"
@@ -1836,9 +1837,9 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]] [[package]]
name = "memmap2" name = "memmap2"
version = "0.9.10" version = "0.9.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "714098028fe011992e1c3962653c96b2d578c4b4bce9036e15ff220319b1e0e3" checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@@ -1855,9 +1856,9 @@ dependencies = [
[[package]] [[package]]
name = "minus" name = "minus"
version = "5.7.1" version = "5.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2657ec5f6a6edc55a85c8db0c572436b612eb036af00e7eee47e0a622095ed96" checksum = "1db1df1b8dd701aa57b41283b50b751b3ebc8fe1406955ec90c53b46b475fa56"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"crossterm", "crossterm",
@@ -1876,7 +1877,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -1918,7 +1919,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2112,9 +2113,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.106" version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@@ -2238,7 +2239,7 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2472,12 +2473,6 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "std_prelude" name = "std_prelude"
version = "0.2.12" version = "0.2.12"
@@ -2547,7 +2542,7 @@ dependencies = [
"getrandom", "getrandom",
"once_cell", "once_cell",
"rustix", "rustix",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2561,16 +2556,16 @@ dependencies = [
[[package]] [[package]]
name = "terminal-colorsaurus" name = "terminal-colorsaurus"
version = "1.0.0" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f7226dad4b1817567c1e2f5d453897ef36abe79def7783af3fa241a694e30b3" checksum = "7a46bb5364467da040298c573c8a95dbf9a512efc039630409a03126e3703e90"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"memchr", "memchr",
"mio", "mio",
"terminal-trx", "terminal-trx",
"windows-sys 0.59.0", "windows-sys",
"xterm-color", "xterm-color",
] ]
@@ -2582,7 +2577,7 @@ checksum = "3b3f27d9a8a177e57545481faec87acb45c6e854ed1e5a3658ad186c106f38ed"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2592,7 +2587,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874"
dependencies = [ dependencies = [
"rustix", "rustix",
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2886,7 +2881,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys",
] ]
[[package]] [[package]]
@@ -2998,15 +2993,6 @@ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.61.2" version = "0.61.2"
+2 -2
View File
@@ -70,13 +70,13 @@ regex = { version = "1.12.3", optional = true }
walkdir = { version = "2.5", optional = true } walkdir = { version = "2.5", optional = true }
bytesize = { version = "2.3.1" } bytesize = { version = "2.3.1" }
encoding_rs = "0.8.35" encoding_rs = "0.8.35"
execute = { version = "0.2.15", optional = true } execute = { version = "0.3.0", optional = true }
terminal-colorsaurus = "1.0" terminal-colorsaurus = "1.0"
unicode-segmentation = "1.13.2" unicode-segmentation = "1.13.2"
itertools = "0.14.0" itertools = "0.14.0"
[dependencies.gix] [dependencies.gix]
version = "0.85" version = "0.86"
optional = true optional = true
default-features = false default-features = false
features = ["sha1", "blob-diff"] features = ["sha1", "blob-diff"]
+1 -1
View File
@@ -902,7 +902,7 @@ cargo install --path . --locked --force
``` ```
If you want to build an application that uses `bat`'s pretty-printing If you want to build an application that uses `bat`'s pretty-printing
features as a library, check out the [the API documentation](https://docs.rs/bat/). features as a library, check out the [API documentation](https://docs.rs/bat/).
Note that you have to use either `regex-onig` or `regex-fancy` as a feature Note that you have to use either `regex-onig` or `regex-fancy` as a feature
when you depend on `bat` as a library. when you depend on `bat` as a library.
+23 -4
View File
@@ -38,22 +38,41 @@ contexts:
scope: markup.underline.link.scheme.log scope: markup.underline.link.scheme.log
push: url-host push: url-host
log_level_lines: log_level_lines:
- match: (?=.*{{error}}) # Prevent retrying each lookahead at every position.
- match: ^(?=.*{{error}})
push: push:
- error_line_meta - error_line_meta
- main_pop_at_eol - main_pop_at_eol
- match: (?=.*{{warning}}) - match: ^(?=.*{{warning}})
push: push:
- warning_line_meta - warning_line_meta
- main_pop_at_eol - main_pop_at_eol
- match: (?=.*{{info}}) - match: ^(?=.*{{info}})
push: push:
- info_line_meta - info_line_meta
- main_pop_at_eol - main_pop_at_eol
- match: (?=.*{{debug}}) - match: ^(?=.*{{debug}})
push: push:
- debug_line_meta - debug_line_meta
- main_pop_at_eol - main_pop_at_eol
# For syntaxes that embed Log after consuming a prefix. Call this context once.
log_level_lines_at_current_position:
- match: (?=.*{{error}})
set:
- error_line_meta
- main_pop_at_eol
- match: (?=.*{{warning}})
set:
- warning_line_meta
- main_pop_at_eol
- match: (?=.*{{info}})
set:
- info_line_meta
- main_pop_at_eol
- match: (?=.*{{debug}})
set:
- debug_line_meta
- main_pop_at_eol
log_levels: log_levels:
- match: '{{error}}' - match: '{{error}}'
scope: markup.error.log scope: markup.error.log
+11 -1
View File
@@ -50,6 +50,17 @@ contexts:
- match: (?=\]) - match: (?=\])
pop: true pop: true
text: text:
- include: text_special
- match: ''
set: classify_log_text
classify_log_text:
- include: scope:text.log#log_level_lines_at_current_position
- match: ''
set: text_body
text_body:
- include: text_special
- include: scope:text.log
text_special:
- match: $ - match: $
pop: true pop: true
- match: '<\w+>' - match: '<\w+>'
@@ -62,4 +73,3 @@ contexts:
escape: \)$ escape: \)$
escape_captures: escape_captures:
0: punctuation.section.block.end.syslog 0: punctuation.section.block.end.syslog
- include: scope:text.log
+10
View File
@@ -83,6 +83,16 @@ Options:
-n, --number -n, --number
Only show line numbers, no other decorations. This is an alias for '--style=numbers' Only show line numbers, no other decorations. This is an alias for '--style=numbers'
-b, --number-nonblank
Only show line numbers for non-blank lines, no other decorations. This is an alias for
'--style=numbers'. Non-blank lines are lines that contain any character before the line
ending, including spaces and tabs. When used together with --number (-n),
--number-nonblank (-b) takes precedence.
Example:
printf 'alpha\n\nbeta\n' | bat -b
numbers 'alpha' and 'beta', but skips the empty line.
--color <when> --color <when>
Specify when to use colored output. The automatic mode only enables colors if an Specify when to use colored output. The automatic mode only enables colors if an
interactive terminal is detected - colors are automatically disabled if the output goes to interactive terminal is detected - colors are automatically disabled if the output goes to
+2
View File
@@ -33,6 +33,8 @@ Options:
Truncate all lines longer than screen width. Alias for '--wrap=never'. Truncate all lines longer than screen width. Alias for '--wrap=never'.
-n, --number -n, --number
Show line numbers (alias for '--style=numbers'). Show line numbers (alias for '--style=numbers').
-b, --number-nonblank
Show line numbers for non-blank lines only (alias for '--style=numbers').
--color <when> --color <when>
When to use colors (*auto*, never, always). When to use colors (*auto*, never, always).
--italic-text <when> --italic-text <when>
+2 -2
View File
@@ -363,11 +363,11 @@ impl HighlightingAssets {
reader: &mut InputReader, reader: &mut InputReader,
) -> Result<Option<SyntaxReferenceInSet<'_>>> { ) -> Result<Option<SyntaxReferenceInSet<'_>>> {
let syntax_set = self.get_syntax_set()?; let syntax_set = self.get_syntax_set()?;
Ok(String::from_utf8(reader.first_line.clone()) Ok(std::str::from_utf8(&reader.first_line)
.ok() .ok()
.and_then(|l| { .and_then(|l| {
// Strip UTF-8 BOM if present // Strip UTF-8 BOM if present
let line = l.strip_prefix('\u{feff}').unwrap_or(&l); let line = l.strip_prefix('\u{feff}').unwrap_or(l);
syntax_set.find_syntax_by_first_line(line) syntax_set.find_syntax_by_first_line(line)
}) })
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })) .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
+39 -1
View File
@@ -59,6 +59,10 @@ pub struct App {
/// (not from config file or environment variables). /// (not from config file or environment variables).
/// This is used to honor the flag when piping output, similar to `cat -n`. /// This is used to honor the flag when piping output, similar to `cat -n`.
number_from_cli: bool, number_from_cli: bool,
/// True if -b / --number-nonblank was passed on the command line
/// (not from config file or environment variables).
/// This is used to honor the flag when piping output, similar to `cat -b`.
number_nonblank_from_cli: bool,
} }
impl App { impl App {
@@ -99,6 +103,29 @@ impl App {
false false
}); });
// Check if the -b / --number-nonblank option was passed on the command line
// (before merging with config file and environment variables).
// This is needed to honor the -b flag when piping output, similar to `cat -b`.
// The same combined-flag logic applies as for -n above.
let number_nonblank_from_cli = wild::args_os().any(|arg| {
let arg_str = arg.to_string_lossy();
if arg_str == "-b" || arg_str == "--number-nonblank" {
return true;
}
// Handle combined short flags
if arg_str.starts_with('-') && !arg_str.starts_with("--") && arg_str.len() > 2 {
let chars: Vec<char> = arg_str.chars().skip(1).collect();
let b_pos = chars.iter().position(|&c| c == 'b');
let p_pos = chars.iter().position(|&c| c == 'p');
if let Some(b) = b_pos {
if p_pos.is_none() || b > p_pos.unwrap() {
return true;
}
}
}
false
});
let matches = Self::matches(interactive_output)?; let matches = Self::matches(interactive_output)?;
if matches.get_flag("help") { if matches.get_flag("help") {
@@ -139,6 +166,7 @@ impl App {
matches, matches,
interactive_output, interactive_output,
number_from_cli, number_from_cli,
number_nonblank_from_cli,
}) })
} }
@@ -454,7 +482,8 @@ impl App {
.map(|s| s.as_str()) .map(|s| s.as_str())
== Some("always") == Some("always")
|| self.matches.get_flag("force-colorization") || self.matches.get_flag("force-colorization")
|| self.number_from_cli), || self.number_from_cli
|| self.number_nonblank_from_cli),
tab_width: self tab_width: self
.matches .matches
.get_one::<String>("tabs") .get_one::<String>("tabs")
@@ -495,6 +524,8 @@ impl App {
), ),
quiet_empty: self.matches.get_flag("quiet-empty"), quiet_empty: self.matches.get_flag("quiet-empty"),
unbuffered: self.matches.get_flag("unbuffered"), unbuffered: self.matches.get_flag("unbuffered"),
number_nonblank: self.matches.get_flag("number-nonblank")
|| self.number_nonblank_from_cli,
theme: theme(self.theme_options()).to_string(), theme: theme(self.theme_options()).to_string(),
visible_lines: match self.matches.try_contains_id("diff").unwrap_or_default() visible_lines: match self.matches.try_contains_id("diff").unwrap_or_default()
&& self.matches.get_flag("diff") && self.matches.get_flag("diff")
@@ -613,6 +644,13 @@ impl App {
]))); ])));
} }
// Only line numbers for non-blank lines if `--number-nonblank`.
if self.matches.get_flag("number-nonblank") || self.number_nonblank_from_cli {
return Some(StyleComponents(HashSet::from([
StyleComponent::LineNumbers,
])));
}
// Plain if `--plain` is specified at least once. // Plain if `--plain` is specified at least once.
if self.matches.get_count("plain") > 0 { if self.matches.get_count("plain") > 0 {
let mut components = HashSet::from([StyleComponent::Plain]); let mut components = HashSet::from([StyleComponent::Plain]);
+18
View File
@@ -97,6 +97,7 @@ pub fn build_app(interactive_output: bool) -> Command {
Arg::new("plain") Arg::new("plain")
.overrides_with("plain") .overrides_with("plain")
.overrides_with("number") .overrides_with("number")
.overrides_with("number-nonblank")
.short('p') .short('p')
.long("plain") .long("plain")
.action(ArgAction::Count) .action(ArgAction::Count)
@@ -277,6 +278,23 @@ pub fn build_app(interactive_output: bool) -> Command {
'--style=numbers'", '--style=numbers'",
), ),
) )
.arg(
Arg::new("number-nonblank")
.long("number-nonblank")
.overrides_with("number-nonblank")
.short('b')
.action(ArgAction::SetTrue)
.help("Show line numbers for non-blank lines only (alias for '--style=numbers').")
.long_help(
"Only show line numbers for non-blank lines, no other decorations. This is an \
alias for '--style=numbers'. Non-blank lines are lines that contain any \
character before the line ending, including spaces and tabs. When used \
together with --number (-n), --number-nonblank (-b) takes precedence.\n\n\
Example:\n \
printf 'alpha\\n\\nbeta\\n' | bat -b\n \
numbers 'alpha' and 'beta', but skips the empty line.",
),
)
.arg( .arg(
Arg::new("color") Arg::new("color")
.long("color") .long("color")
+4
View File
@@ -119,6 +119,10 @@ pub struct Config<'a> {
/// Whether or not to use unbuffered input reading for streaming use cases /// Whether or not to use unbuffered input reading for streaming use cases
pub unbuffered: bool, pub unbuffered: bool,
/// Only number non-blank lines (like `cat -b`). Has no effect if `style_components` doesn't
/// include `LineNumbers`.
pub number_nonblank: bool,
} }
#[cfg(all(feature = "minimal-application", feature = "paging"))] #[cfg(all(feature = "minimal-application", feature = "paging"))]
+12 -1
View File
@@ -276,10 +276,21 @@ impl Controller<'_> {
} }
if !reached_eof { if !reached_eof {
if reader.read_line(&mut current_line_buffer)? { if reader.read_line(&mut current_line_buffer)? {
// Fill the buffer // Fill the buffer. In number-nonblank mode, don't advance the
// line counter for empty lines (content-free lines that contain
// only the line terminator).
if self.config.number_nonblank
&& current_line_buffer
.iter()
.all(|&b| b == b'\r' || b == b'\n')
{
buffered_lines
.push_back((mem::take(&mut current_line_buffer), current_line_number));
} else {
buffered_lines buffered_lines
.push_back((mem::take(&mut current_line_buffer), current_line_number)); .push_back((mem::take(&mut current_line_buffer), current_line_number));
current_line_number += 1; current_line_number += 1;
}
} else { } else {
// No more data to read // No more data to read
reached_eof = true; reached_eof = true;
+8
View File
@@ -45,6 +45,14 @@ impl Decoration for LineNumberDecoration {
continuation: bool, continuation: bool,
_printer: &InteractivePrinter, _printer: &InteractivePrinter,
) -> DecorationText { ) -> DecorationText {
if line_number == 0 {
// Blank line in number-nonblank mode: show empty space instead of a number.
return DecorationText {
text: self.color.paint(" ".repeat(self.width())).to_string(),
width: self.width(),
};
}
if continuation { if continuation {
if line_number >= self.cached_wrap_invalid_at { if line_number >= self.cached_wrap_invalid_at {
let new_width = self.cached_wrap.width + 1; let new_width = self.cached_wrap.width + 1;
+8 -1
View File
@@ -738,10 +738,17 @@ impl Printer for InteractivePrinter<'_> {
// Line decorations. // Line decorations.
if self.panel_width > 0 { if self.panel_width > 0 {
let display_line_number =
if self.config.number_nonblank && line.trim_end_matches(['\r', '\n']).is_empty() {
0
} else {
line_number
};
let decorations = self let decorations = self
.decorations .decorations
.iter() .iter()
.map(|d| d.generate(line_number, false, self)); .map(|d| d.generate(display_line_number, false, self));
for deco in decorations { for deco in decorations {
write!(handle, "{} ", deco.text)?; write!(handle, "{} ", deco.text)?;
+202
View File
@@ -213,6 +213,69 @@ fn numbers_honored_from_cli_when_preceeded_by_plain_in_loop_through_mode() {
.stdout(" 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n 5 line 5\n 6 line 6\n 7 line 7\n 8 line 8\n 9 line 9\n 10 line 10\n"); .stdout(" 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n 5 line 5\n 6 line 6\n 7 line 7\n 8 line 8\n 9 line 9\n 10 line 10\n");
} }
#[test]
fn number_nonblank_style() {
bat()
.arg("empty_lines.txt")
.arg("-b")
.arg("--decorations=always")
.assert()
.success()
.stdout(" 1 line 1\n \n \n \n 2 line 5\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 3 line 20\n 4 line 21\n \n \n 5 line 24\n \n 6 line 26\n \n \n \n 7 line 30\n");
}
#[test]
fn number_nonblank_from_cli_in_loop_through_mode() {
bat()
.arg("empty_lines.txt")
.arg("-b")
.assert()
.success()
.stdout(" 1 line 1\n \n \n \n 2 line 5\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 3 line 20\n 4 line 21\n \n \n 5 line 24\n \n 6 line 26\n \n \n \n 7 line 30\n");
}
#[test]
fn number_nonblank_takes_precedence_over_number() {
// -bn should behave like -b
bat()
.arg("empty_lines.txt")
.arg("-bn")
.arg("--decorations=always")
.assert()
.success()
.stdout(" 1 line 1\n \n \n \n 2 line 5\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 3 line 20\n 4 line 21\n \n \n 5 line 24\n \n 6 line 26\n \n \n \n 7 line 30\n");
// -nb should also behave like -b
bat()
.arg("empty_lines.txt")
.arg("-nb")
.arg("--decorations=always")
.assert()
.success()
.stdout(" 1 line 1\n \n \n \n 2 line 5\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 3 line 20\n 4 line 21\n \n \n 5 line 24\n \n 6 line 26\n \n \n \n 7 line 30\n");
}
#[test]
fn number_nonblank_ignored_when_followed_by_plain() {
bat()
.arg("empty_lines.txt")
.arg("-bp")
.arg("--decorations=auto")
.assert()
.success()
.stdout("line 1\n\n\n\nline 5\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nline 20\nline 21\n\n\nline 24\n\nline 26\n\n\n\nline 30\n");
}
#[test]
fn piped_output_with_number_nonblank_flag() {
bat()
.arg("-b")
.write_stdin("hello\n\nworld\n")
.assert()
.success()
.stdout(" 1 hello\n \n 2 world\n");
}
#[test] #[test]
fn line_range_2_3() { fn line_range_2_3() {
bat() bat()
@@ -2559,6 +2622,145 @@ fn no_first_line_fallback_when_mapping_to_invalid_syntax() {
.stderr(predicate::str::contains("unknown syntax: 'InvalidSyntax'")); .stderr(predicate::str::contains("unknown syntax: 'InvalidSyntax'"));
} }
#[test]
fn stdin_detects_bash_from_first_line() {
let content = "#!/bin/bash\necho hi\n";
let detected_output = bat()
.arg("--color=always")
.arg("--style=plain")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
let explicit_output = bat()
.arg("--color=always")
.arg("--style=plain")
.arg("--language=bash")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
assert_eq!(
from_utf8(&detected_output).expect("output is valid utf-8"),
from_utf8(&explicit_output).expect("output is valid utf-8")
);
}
#[test]
fn stdin_detects_diff_from_first_line() {
let content = "diff --git a/x b/y\n--- a/x\n+++ b/y\n@@ -1 +1 @@\n-old\n+new\n";
let detected_output = bat()
.arg("--color=always")
.arg("--style=plain")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
let explicit_output = bat()
.arg("--color=always")
.arg("--style=plain")
.arg("--language=diff")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
assert_eq!(
from_utf8(&detected_output).expect("output is valid utf-8"),
from_utf8(&explicit_output).expect("output is valid utf-8")
);
}
#[test]
fn empty_stdin_does_not_detect_syntax() {
bat()
.arg("--color=always")
.arg("--style=plain")
.write_stdin("")
.assert()
.success()
.stdout("")
.stderr("");
}
#[test]
fn binary_stdin_does_not_detect_syntax_from_invalid_utf8_first_line() {
let content = b"#!/bin/bash\xff\necho hi\n";
let detected_output = bat()
.arg("--binary=as-text")
.arg("--color=always")
.arg("--style=plain")
.write_stdin(content.as_slice())
.assert()
.success()
.get_output()
.stdout
.clone();
let plain_text_output = bat()
.arg("--binary=as-text")
.arg("--color=always")
.arg("--style=plain")
.arg("--language=txt")
.write_stdin(content.as_slice())
.assert()
.success()
.get_output()
.stdout
.clone();
assert_eq!(
from_utf8(&detected_output).expect("output is valid utf-8"),
from_utf8(&plain_text_output).expect("output is valid utf-8")
);
}
#[test]
fn explicit_language_overrides_stdin_first_line_detection() {
let content = "diff --git a/x b/y\n--- a/x\n+++ b/y\n@@ -1 +1 @@\n-old\n+new\n";
let detected_output = bat()
.arg("--color=always")
.arg("--style=plain")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
let explicit_output = bat()
.arg("--color=always")
.arg("--style=plain")
.arg("--language=json")
.arg("-")
.write_stdin(content)
.assert()
.success()
.get_output()
.stdout
.clone();
assert_ne!(
from_utf8(&detected_output).expect("output is valid utf-8"),
from_utf8(&explicit_output).expect("output is valid utf-8")
);
}
#[test] #[test]
fn fallback_syntax_is_used_when_no_syntax_is_detected() { fn fallback_syntax_is_used_when_no_syntax_is_detected() {
let content = "# comment\nfoo=bar\n"; let content = "# comment\nfoo=bar\n";