@@ -5,7 +5,7 @@ use std::{borrow::Cow, convert::TryFrom, fmt::Display, str::FromStr};
5
5
use nom:: AsChar ;
6
6
#[ cfg( not( target_os = "windows" ) ) ]
7
7
use pwd:: Passwd ;
8
- use quick_error:: quick_error;
8
+ use quick_error:: { quick_error, ResultExt } ;
9
9
#[ cfg( feature = "serde" ) ]
10
10
use serde:: { Serialize , Serializer } ;
11
11
@@ -286,9 +286,9 @@ quick_error! {
286
286
Missing { what: & ' static str } {
287
287
display( "{} is missing" , what)
288
288
}
289
- Utf8Conversion ( err: git_features:: path:: Utf8Error ) {
290
- display( "Ill-formed UTF-8 in git install dir or home dir" )
291
- from ( )
289
+ Utf8Conversion ( what : & ' static str , err: git_features:: path:: Utf8Error ) {
290
+ display( "Ill-formed UTF-8 in {}" , what )
291
+ context ( what : & ' static str , err : git_features :: path :: Utf8Error ) -> ( what , err )
292
292
}
293
293
UsernameConversion ( err: std:: str :: Utf8Error ) {
294
294
display( "Ill-formed UTF-8 in username" )
@@ -323,7 +323,6 @@ impl<'a> TryFrom<Cow<'a, [u8]>> for Path<'a> {
323
323
}
324
324
325
325
impl Path < ' _ > {
326
-
327
326
/// Interpolates path value
328
327
///
329
328
/// Path value can be given a string that begins with `~/` or `~user/` or `%(prefix)/`
@@ -348,7 +347,8 @@ impl Path<'_> {
348
347
if path. starts_with ( PREFIX ) {
349
348
let mut expanded = git_features:: path:: into_bytes ( git_install_dir. ok_or ( PathError :: Missing {
350
349
what : "git install dir" ,
351
- } ) ?) ?
350
+ } ) ?)
351
+ . context ( "git install dir" ) ?
352
352
. into_owned ( ) ;
353
353
let ( _prefix, val) = path. split_at ( PREFIX . len ( ) - 1 ) ;
354
354
expanded. extend ( val) ;
@@ -357,7 +357,9 @@ impl Path<'_> {
357
357
} )
358
358
} else if path. starts_with ( b"~/" ) {
359
359
let home_path = dirs:: home_dir ( ) . ok_or ( PathError :: Missing { what : "home dir" } ) ?;
360
- let mut expanded = git_features:: path:: into_bytes ( home_path) ?. into_owned ( ) ;
360
+ let mut expanded = git_features:: path:: into_bytes ( home_path)
361
+ . context ( "home dir" ) ?
362
+ . into_owned ( ) ;
361
363
let ( _prefix, val) = path. split_at ( SLASH . len ( ) ) ;
362
364
expanded. extend ( val) ;
363
365
let expanded = git_features:: path:: convert:: to_unix_separators ( expanded) ;
0 commit comments