File tree Expand file tree Collapse file tree 2 files changed +53
-43
lines changed Expand file tree Collapse file tree 2 files changed +53
-43
lines changed Original file line number Diff line number Diff line change 3
3
use 5.008;
4
4
use strict;
5
5
use warnings;
6
- use Git;
6
+ use Git qw( unquote_path ) ;
7
7
use Git::I18N;
8
8
9
9
binmode (STDOUT , " :raw" );
@@ -175,47 +175,6 @@ sub run_cmd_pipe {
175
175
}
176
176
chomp ($GIT_DIR );
177
177
178
- my %cquote_map = (
179
- " b" => chr (8),
180
- " t" => chr (9),
181
- " n" => chr (10),
182
- " v" => chr (11),
183
- " f" => chr (12),
184
- " r" => chr (13),
185
- " \\ " => " \\ " ,
186
- " \042 " => " \042 " ,
187
- );
188
-
189
- sub unquote_path {
190
- local ($_ ) = @_ ;
191
- my ($retval , $remainder );
192
- if (!/^\042(.*)\042$/ ) {
193
- return $_ ;
194
- }
195
- ($_ , $retval ) = ($1 , " " );
196
- while (/ ^([^\\ ]*)\\ (.*)$ / ) {
197
- $remainder = $2 ;
198
- $retval .= $1 ;
199
- for ($remainder ) {
200
- if (/ ^([0-3][0-7][0-7])(.*)$ / ) {
201
- $retval .= chr (oct ($1 ));
202
- $_ = $2 ;
203
- last ;
204
- }
205
- if (/ ^([\\\042 btnvfr])(.*)$ / ) {
206
- $retval .= $cquote_map {$1 };
207
- $_ = $2 ;
208
- last ;
209
- }
210
- # This is malformed -- just return it as-is for now.
211
- return $_ [0];
212
- }
213
- $_ = $remainder ;
214
- }
215
- $retval .= $_ ;
216
- return $retval ;
217
- }
218
-
219
178
sub refresh {
220
179
my $fh ;
221
180
open $fh , ' git update-index --refresh |'
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ require Exporter;
61
61
remote_refs prompt
62
62
get_tz_offset get_record
63
63
credential credential_read credential_write
64
- temp_acquire temp_is_locked temp_release temp_reset temp_path) ;
64
+ temp_acquire temp_is_locked temp_release temp_reset temp_path
65
+ unquote_path) ;
65
66
66
67
67
68
=head1 DESCRIPTION
@@ -1451,6 +1452,56 @@ sub prefix_lines {
1451
1452
return $string ;
1452
1453
}
1453
1454
1455
+ =item unquote_path ( PATH )
1456
+
1457
+ Unquote a quoted path containing c-escapes as returned by ls-files etc.
1458
+ when not using -z or when parsing the output of diff -u.
1459
+
1460
+ =cut
1461
+
1462
+ {
1463
+ my %cquote_map = (
1464
+ " b" => chr (8),
1465
+ " t" => chr (9),
1466
+ " n" => chr (10),
1467
+ " v" => chr (11),
1468
+ " f" => chr (12),
1469
+ " r" => chr (13),
1470
+ " \\ " => " \\ " ,
1471
+ " \042 " => " \042 " ,
1472
+ );
1473
+
1474
+ sub unquote_path {
1475
+ local ($_ ) = @_ ;
1476
+ my ($retval , $remainder );
1477
+ if (!/^\042(.*)\042$/ ) {
1478
+ return $_ ;
1479
+ }
1480
+ ($_ , $retval ) = ($1 , " " );
1481
+ while (/ ^([^\\ ]*)\\ (.*)$ / ) {
1482
+ $remainder = $2 ;
1483
+ $retval .= $1 ;
1484
+ for ($remainder ) {
1485
+ if (/ ^([0-3][0-7][0-7])(.*)$ / ) {
1486
+ $retval .= chr (oct ($1 ));
1487
+ $_ = $2 ;
1488
+ last ;
1489
+ }
1490
+ if (/ ^([\\\042 btnvfr])(.*)$ / ) {
1491
+ $retval .= $cquote_map {$1 };
1492
+ $_ = $2 ;
1493
+ last ;
1494
+ }
1495
+ # This is malformed -- just return it as-is for now.
1496
+ return $_ [0];
1497
+ }
1498
+ $_ = $remainder ;
1499
+ }
1500
+ $retval .= $_ ;
1501
+ return $retval ;
1502
+ }
1503
+ }
1504
+
1454
1505
=item get_comment_line_char ( )
1455
1506
1456
1507
Gets the core.commentchar configuration value.
You can’t perform that action at this time.
0 commit comments