@@ -643,7 +643,7 @@ def ls_tree(sha, opts = {})
643
643
args << opts [ :path ] if opts [ :path ]
644
644
645
645
command_lines ( 'ls-tree' , *args ) . each do |line |
646
- ( info , filenm ) = line . split ( " \t " )
646
+ ( info , filenm ) = split_status_line ( line )
647
647
( mode , type , sha ) = info . split
648
648
data [ type ] [ filenm ] = { mode : mode , sha : sha }
649
649
end
@@ -905,9 +905,9 @@ def ls_files(location = nil)
905
905
location ||= '.'
906
906
{ } . tap do |files |
907
907
command_lines ( 'ls-files' , '--stage' , location ) . each do |line |
908
- ( info , file ) = line . split ( " \t " )
908
+ ( info , file ) = split_status_line ( line )
909
909
( mode , sha , stage ) = info . split
910
- files [ unescape_quoted_path ( file ) ] = {
910
+ files [ file ] = {
911
911
path : file , mode_index : mode , sha_index : sha , stage : stage
912
912
}
913
913
end
@@ -956,7 +956,9 @@ def ignored_files
956
956
end
957
957
958
958
def untracked_files
959
- command_lines ( 'ls-files' , '--others' , '--exclude-standard' , chdir : @git_work_dir )
959
+ command_lines ( 'ls-files' , '--others' , '--exclude-standard' , chdir : @git_work_dir ) . map do |f |
960
+ unescape_quoted_path ( f )
961
+ end
960
962
end
961
963
962
964
def config_remote ( name )
@@ -1602,7 +1604,7 @@ def self.warn_if_old_command(lib) # rubocop:disable Naming/PredicateMethod
1602
1604
1603
1605
def parse_diff_path_status ( args )
1604
1606
command_lines ( 'diff' , *args ) . each_with_object ( { } ) do |line , memo |
1605
- status , path = line . split ( " \t " )
1607
+ status , path = split_status_line ( line )
1606
1608
memo [ path ] = status
1607
1609
end
1608
1610
end
@@ -1727,7 +1729,7 @@ def parse_diff_stats_output(lines)
1727
1729
1728
1730
def parse_stat_lines ( lines )
1729
1731
lines . map do |line |
1730
- insertions_s , deletions_s , filename = line . split ( " \t " )
1732
+ insertions_s , deletions_s , filename = split_status_line ( line )
1731
1733
{
1732
1734
filename : filename ,
1733
1735
insertions : insertions_s . to_i ,
@@ -1736,6 +1738,12 @@ def parse_stat_lines(lines)
1736
1738
end
1737
1739
end
1738
1740
1741
+ def split_status_line ( line )
1742
+ parts = line . split ( "\t " )
1743
+ parts [ -1 ] = unescape_quoted_path ( parts [ -1 ] ) if parts . any?
1744
+ parts
1745
+ end
1746
+
1739
1747
def build_final_stats_hash ( file_stats )
1740
1748
{
1741
1749
total : build_total_stats ( file_stats ) ,
@@ -1965,7 +1973,7 @@ def diff_as_hash(diff_command, opts = [])
1965
1973
# update index before diffing to avoid spurious diffs
1966
1974
command ( 'status' )
1967
1975
command_lines ( diff_command , *opts ) . each_with_object ( { } ) do |line , memo |
1968
- info , file = line . split ( " \t " )
1976
+ info , file = split_status_line ( line )
1969
1977
mode_src , mode_dest , sha_src , sha_dest , type = info . split
1970
1978
1971
1979
memo [ file ] = {
0 commit comments