Unified · Split
| @@ -432,7 +432,7 @@ impl<'event> GitConfig<'event> { · 431 unmodified lines | |||
| 432 | let mut paths = vec![]; | 432 | let mut paths = vec![]; |
| 433 | 433 | ||
| 434 | if env::var("GIT_CONFIG_NO_SYSTEM").is_err() { | 434 | if env::var("GIT_CONFIG_NO_SYSTEM").is_err() { |
| 435 | if let Ok(git_config_system) = env::var("GIT_CONFIG_SYSTEM") { | 435 | if let Some(git_config_system) = env::var_os("GIT_CONFIG_SYSTEM") { |
| 436 | paths.push(PathBuf::from(git_config_system)) | 436 | paths.push(PathBuf::from(git_config_system)) |
| 437 | } else { | 437 | } else { |
| 438 | // In git the fallback is set to a build time macro which defaults to /etc/gitconfig | 438 | // In git the fallback is set to a build time macro which defaults to /etc/gitconfig |
| @@ -440,24 +440,24 @@ impl<'event> GitConfig<'event> { · 1 unmodified line | |||
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | if let Ok(git_config_global) = env::var("GIT_CONFIG_GLOBAL") { | 443 | if let Some(git_config_global) = env::var_os("GIT_CONFIG_GLOBAL") { |
| 444 | paths.push(PathBuf::from(git_config_global)); | 444 | paths.push(PathBuf::from(git_config_global)); |
| 445 | } else { | 445 | } else { |
| 446 | // Divergence from git-config(1) | 446 | // Divergence from git-config(1) |
| 447 | // These two are supposed to share the same scope and override | 447 | // These two are supposed to share the same scope and override |
| 448 | // rather than append according to git-config(1) documentation. | 448 | // rather than append according to git-config(1) documentation. |
| 449 | if let Ok(xdg_config_home) = env::var("XDG_CONFIG_HOME") { | 449 | if let Some(xdg_config_home) = env::var_os("XDG_CONFIG_HOME") { |
| 450 | paths.push(PathBuf::from(xdg_config_home).join("git/config")); | 450 | paths.push(PathBuf::from(xdg_config_home).join("git/config")); |
| 451 | } else if let Ok(home) = env::var("HOME") { | 451 | } else if let Some(home) = env::var_os("HOME") { |
| 452 | paths.push(PathBuf::from(home).join(".config/git/config")); | 452 | paths.push(PathBuf::from(home).join(".config/git/config")); |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | if let Ok(home) = env::var("HOME") { | 455 | if let Some(home) = env::var_os("HOME") { |
| 456 | paths.push(PathBuf::from(home).join(".gitconfig")); | 456 | paths.push(PathBuf::from(home).join(".gitconfig")); |
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | if let Ok(git_dir) = env::var("GIT_DIR") { | 460 | if let Some(git_dir) = env::var_os("GIT_DIR") { |
| 461 | paths.push(PathBuf::from(git_dir).join("config")); | 461 | paths.push(PathBuf::from(git_dir).join("config")); |
| 462 | } | 462 | } |
| 463 | 463 | ||
| @@ -485,8 +485,8 @@ impl<'event> GitConfig<'event> { · 21 unmodified lines | |||
| 485 | for i in 0..count { | 485 | for i in 0..count { |
| 486 | let key = | 486 | let key = |
| 487 | env::var(format!("GIT_CONFIG_KEY_{}", i)).map_err(|_| from_env::Error::InvalidKeyId { key_id: i })?; | 487 | env::var(format!("GIT_CONFIG_KEY_{}", i)).map_err(|_| from_env::Error::InvalidKeyId { key_id: i })?; |
| 488 | let value = env::var(format!("GIT_CONFIG_VALUE_{}", i)) | 488 | let value = env::var_os(format!("GIT_CONFIG_VALUE_{}", i)) |
| 489 | .map_err(|_| from_env::Error::InvalidValueId { value_id: i })?; | 489 | .ok_or_else(|| from_env::Error::InvalidValueId { value_id: i })?; |
| 490 | if let Some((section_name, maybe_subsection)) = key.split_once('.') { | 490 | if let Some((section_name, maybe_subsection)) = key.split_once('.') { |
| 491 | let (subsection, key) = if let Some((subsection, key)) = maybe_subsection.rsplit_once('.') { | 491 | let (subsection, key) = if let Some((subsection, key)) = maybe_subsection.rsplit_once('.') { |
| 492 | (Some(subsection), key) | 492 | (Some(subsection), key) |
| @@ -507,7 +507,7 @@ impl<'event> GitConfig<'event> { · 14 unmodified lines | |||
| 507 | 507 | ||
| 508 | section.push( | 508 | section.push( |
| 509 | Cow::<str>::Owned(key.to_string()).into(), | 509 | Cow::<str>::Owned(key.to_string()).into(), |
| 510 | Cow::Owned(value.into_bytes()), | 510 | Cow::Owned(git_path::into_bstr(PathBuf::from(value)).into_owned().into()), |
| 511 | ); | 511 | ); |
| 512 | } else { | 512 | } else { |
| 513 | return Err(from_env::Error::InvalidKeyValue { | 513 | return Err(from_env::Error::InvalidKeyValue { |