History

feat: add `env::args_os_opt()` which takes an argument to determine input unicode-decomposition

This allows for the possibility to respect `core.precomposeUnicode` should one already have that value.

Sebastian Thiel committed 2 years ago

Commit a7e606b1 parent eace8bf3 files · +14 −16Browse files

Unified · Split

3 files
  1. Cargo.lock +0 −1
  2. gix/Cargo.toml +0 −3
  3. gix/src/env.rs +14 −12
Cargo.lock+0−1
@@ -1392,7 +1392,6 @@ dependencies = [ · 1391 unmodified lines
1392 "signal-hook",1392 "signal-hook",
1393 "smallvec",1393 "smallvec",
1394 "thiserror",1394 "thiserror",
1395 "unicode-normalization",
1396 "walkdir",1395 "walkdir",
1397]1396]
1398 1397
gix/Cargo.toml+0−3
@@ -300,9 +300,6 @@ parking_lot = "0.12.1" · 299 unmodified lines
300 300
301document-features = { version = "0.2.0", optional = true }301document-features = { version = "0.2.0", optional = true }
302 302
303[target.'cfg(target_vendor = "apple")'.dependencies]
304unicode-normalization = { version = "0.1.19", default-features = false }
305
306[dev-dependencies]303[dev-dependencies]
307gix-testtools = { path = "../tests/tools" }304gix-testtools = { path = "../tests/tools" }
308is_ci = "1.1.1"305is_ci = "1.1.1"
gix/src/env.rs+14−12
@@ -12,21 +12,23 @@ pub fn agent() -> &'static str { · 11 unmodified lines
12 concat!("oxide-", env!("CARGO_PKG_VERSION"))12 concat!("oxide-", env!("CARGO_PKG_VERSION"))
13}13}
14 14
15/// Equivalent to `std::env::args_os()`, but with precomposed unicode on `MacOS` and other apple platforms.
16#[cfg(not(target_vendor = "apple"))]
17pub fn args_os() -> impl Iterator<Item = OsString> {
18 std::env::args_os()
19}
20
21/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.15/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.
16/// It does not change the input arguments on any other platform.
22///17///
23/// Note that this ignores `core.precomposeUnicode` as git-config isn't available yet. It's default enabled in modern git though.18/// Note that this ignores `core.precomposeUnicode` as git-config isn't available yet. It's default enabled in modern git though,
24#[cfg(target_vendor = "apple")]19/// and generally decomposed unicode is nothing one would want in a git repository.
25pub fn args_os() -> impl Iterator<Item = OsString> {20pub fn args_os() -> impl Iterator<Item = OsString> {
26 use unicode_normalization::UnicodeNormalization;21 args_os_opt(cfg!(target_vendor = "apple"))
27 std::env::args_os().map(|arg| match arg.to_str() {22}
28 Some(arg) => arg.nfc().collect::<String>().into(),23
29 None => arg,24/// Like [`args_os()`], but with the `precompose_unicode` parameter akin to `core.precomposeUnicode` in the Git configuration.
25pub fn args_os_opt(precompose_unicode: bool) -> impl Iterator<Item = OsString> {
26 std::env::args_os().map(move |arg| {
27 if precompose_unicode {
28 gix_utils::str::precompose_os_string(arg.into()).into_owned()
29 } else {
30 arg
31 }
30 })32 })
31}33}
32 34

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t