@@ -31,12 +31,16 @@ class CheckoutError( Exception ):
3131 The .failed_files attribute contains a list of relative paths that failed
3232 to be checked out as they contained changes that did not exist in the index.
3333
34+ The .failed_reasons attribute contains a string informing about the actual
35+ cause of the issue.
36+
3437 The .valid_files attribute contains a list of relative paths to files that
3538 were checked out successfully and hence match the version stored in the
3639 index"""
37- def __init__ (self , message , failed_files , valid_files ):
40+ def __init__ (self , message , failed_files , valid_files , failed_reasons ):
3841 Exception .__init__ (self , message )
3942 self .failed_files = failed_files
43+ self .failed_reasons = failed_reasons
4044 self .valid_files = valid_files
4145
4246 def __str__ (self ):
@@ -1101,6 +1105,7 @@ def handle_stderr(proc, iter_checked_out_files):
11011105 # line contents:
11021106 # git-checkout-index: this already exists
11031107 failed_files = list ()
1108+ failed_reasons = list ()
11041109 unknown_lines = list ()
11051110 endings = (' already exists' , ' is not in the cache' , ' does not exist at stage' , ' is unmerged' )
11061111 for line in stderr .splitlines ():
@@ -1109,8 +1114,10 @@ def handle_stderr(proc, iter_checked_out_files):
11091114 unlink_issue = "unable to unlink old '"
11101115 if line .endswith (is_a_dir ):
11111116 failed_files .append (line [:- len (is_a_dir )])
1117+ failed_reasons .append (is_a_dir )
11121118 elif line .startswith (unlink_issue ):
11131119 failed_files .append (line [len (unlink_issue ):line .rfind ("'" )])
1120+ failed_reasons .append (unlink_issue )
11141121 else :
11151122 unknown_lines .append (line )
11161123 continue
@@ -1119,6 +1126,7 @@ def handle_stderr(proc, iter_checked_out_files):
11191126 for e in endings :
11201127 if line .endswith (e ):
11211128 failed_files .append (line [20 :- len (e )])
1129+ failed_reasons .append (e )
11221130 break
11231131 # END if ending matches
11241132 # END for each possible ending
@@ -1127,7 +1135,7 @@ def handle_stderr(proc, iter_checked_out_files):
11271135 raise GitCommandError (("git-checkout-index" , ), 128 , stderr )
11281136 if failed_files :
11291137 valid_files = list (set (iter_checked_out_files ) - set (failed_files ))
1130- raise CheckoutError ("Some files could not be checked out from the index due to local modifications" , failed_files , valid_files )
1138+ raise CheckoutError ("Some files could not be checked out from the index due to local modifications" , failed_files , valid_files , failed_reasons )
11311139 # END stderr handler
11321140
11331141
0 commit comments