@@ -31,12 +31,16 @@ class CheckoutError( Exception ):
31
31
The .failed_files attribute contains a list of relative paths that failed
32
32
to be checked out as they contained changes that did not exist in the index.
33
33
34
+ The .failed_reasons attribute contains a string informing about the actual
35
+ cause of the issue.
36
+
34
37
The .valid_files attribute contains a list of relative paths to files that
35
38
were checked out successfully and hence match the version stored in the
36
39
index"""
37
- def __init__ (self , message , failed_files , valid_files ):
40
+ def __init__ (self , message , failed_files , valid_files , failed_reasons ):
38
41
Exception .__init__ (self , message )
39
42
self .failed_files = failed_files
43
+ self .failed_reasons = failed_reasons
40
44
self .valid_files = valid_files
41
45
42
46
def __str__ (self ):
@@ -1101,6 +1105,7 @@ def handle_stderr(proc, iter_checked_out_files):
1101
1105
# line contents:
1102
1106
# git-checkout-index: this already exists
1103
1107
failed_files = list ()
1108
+ failed_reasons = list ()
1104
1109
unknown_lines = list ()
1105
1110
endings = (' already exists' , ' is not in the cache' , ' does not exist at stage' , ' is unmerged' )
1106
1111
for line in stderr .splitlines ():
@@ -1109,8 +1114,10 @@ def handle_stderr(proc, iter_checked_out_files):
1109
1114
unlink_issue = "unable to unlink old '"
1110
1115
if line .endswith (is_a_dir ):
1111
1116
failed_files .append (line [:- len (is_a_dir )])
1117
+ failed_reasons .append (is_a_dir )
1112
1118
elif line .startswith (unlink_issue ):
1113
1119
failed_files .append (line [len (unlink_issue ):line .rfind ("'" )])
1120
+ failed_reasons .append (unlink_issue )
1114
1121
else :
1115
1122
unknown_lines .append (line )
1116
1123
continue
@@ -1119,6 +1126,7 @@ def handle_stderr(proc, iter_checked_out_files):
1119
1126
for e in endings :
1120
1127
if line .endswith (e ):
1121
1128
failed_files .append (line [20 :- len (e )])
1129
+ failed_reasons .append (e )
1122
1130
break
1123
1131
# END if ending matches
1124
1132
# END for each possible ending
@@ -1127,7 +1135,7 @@ def handle_stderr(proc, iter_checked_out_files):
1127
1135
raise GitCommandError (("git-checkout-index" , ), 128 , stderr )
1128
1136
if failed_files :
1129
1137
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 )
1131
1139
# END stderr handler
1132
1140
1133
1141
0 commit comments