@@ -363,13 +363,12 @@ sub cmd_dcommit {
363
363
my $head = shift ;
364
364
$head ||= ' HEAD' ;
365
365
my @refs ;
366
- my ($url , $rev , $uuid ) = working_head_info($head , \@refs );
367
- my $c = $refs [-1];
368
- unless (defined $url && defined $rev && defined $uuid ) {
366
+ my ($url , $rev , $uuid , $gs ) = working_head_info($head , \@refs );
367
+ unless ($gs ) {
369
368
die " Unable to determine upstream SVN information from " ,
370
369
" $head history\n " ;
371
370
}
372
- my $gs = Git::SVN -> find_by_url( $url ) ;
371
+ my $c = $refs [-1] ;
373
372
my $last_rev ;
374
373
foreach my $d (@refs ) {
375
374
if (!verify_ref(" $d ~1" )) {
@@ -431,16 +430,11 @@ sub cmd_dcommit {
431
430
432
431
sub cmd_rebase {
433
432
command_noisy(qw/ update-index --refresh/ );
434
- my $url = ( working_head_info(' HEAD' ))[0] ;
435
- if (! defined $url ) {
433
+ my ( $url , $rev , $uuid , $gs ) = working_head_info(' HEAD' );
434
+ unless ( $gs ) {
436
435
die " Unable to determine upstream SVN information from " ,
437
436
" working tree history\n " ;
438
437
}
439
-
440
- my $gs = Git::SVN-> find_by_url($url );
441
- unless ($gs ) {
442
- die " Unable to determine remote information from URL: $url \n " ;
443
- }
444
438
if (command(qw/ diff-index HEAD --/ )) {
445
439
print STDERR " Cannot rebase with uncommited changes:\n " ;
446
440
command_noisy(' status' );
@@ -453,8 +447,8 @@ sub cmd_rebase {
453
447
}
454
448
455
449
sub cmd_show_ignore {
456
- my $url = (:: working_head_info(' HEAD' ))[0] ;
457
- my $gs = Git::SVN -> find_by_url( $url ) || Git::SVN-> new;
450
+ my ( $url , $rev , $uuid , $gs ) = working_head_info(' HEAD' );
451
+ $gs ||= Git::SVN-> new;
458
452
my $r = (defined $_revision ? $_revision : $gs -> ra-> get_latest_revnum);
459
453
$gs -> traverse_ignore(\*STDOUT , $gs -> {path }, $r );
460
454
}
@@ -776,16 +770,23 @@ sub cmt_metadata {
776
770
777
771
sub working_head_info {
778
772
my ($head , $refs ) = @_ ;
779
- my ($url , $rev , $uuid );
780
773
my ($fh , $ctx ) = command_output_pipe(' rev-list' , $head );
781
774
while (<$fh >) {
782
775
chomp ;
783
- ($url , $rev , $uuid ) = cmt_metadata($_ );
784
- last if (defined $url && defined $rev && defined $uuid );
776
+ my ($url , $rev , $uuid ) = cmt_metadata($_ );
777
+ if (defined $url && defined $rev ) {
778
+ if (my $gs = Git::SVN-> find_by_url($url )) {
779
+ my $c = $gs -> rev_db_get($rev );
780
+ if ($c && $c eq $_ ) {
781
+ close $fh ; # break the pipe
782
+ return ($url , $rev , $uuid , $gs );
783
+ }
784
+ }
785
+ }
785
786
unshift @$refs , $_ if $refs ;
786
787
}
787
- close $fh ; # break the pipe
788
- ($url , $rev , $uuid );
788
+ command_close_pipe( $fh , $ctx );
789
+ (undef , undef , undef , undef );
789
790
}
790
791
791
792
package Git::SVN ;
@@ -3262,12 +3263,19 @@ package Git::SVN::Log;
3262
3263
sub cmt_showable {
3263
3264
my ($c ) = @_ ;
3264
3265
return 1 if defined $c -> {r };
3266
+
3267
+ # big commit message got truncated by the 16k pretty buffer in rev-list
3265
3268
if ($c -> {l } && $c -> {l }-> [-1] eq " ...\n " &&
3266
3269
$c -> {a_raw } =~ / \@ ([a-f\d\- ]+)>$ / ) {
3270
+ @{$c -> {l }} = ();
3267
3271
my @log = command(qw/ cat-file commit/ , $c -> {c });
3268
- shift @log while ($log [0] ne " \n " );
3272
+
3273
+ # shift off the headers
3274
+ shift @log while ($log [0] ne ' ' );
3269
3275
shift @log ;
3270
- @{$c -> {l }} = grep !/^git-svn-id: /, @log ;
3276
+
3277
+ # TODO: make $c->{l} not have a trailing newline in the future
3278
+ @{$c -> {l }} = map { " $_ \n " } grep !/^git-svn-id: /, @log ;
3271
3279
3272
3280
(undef , $c -> {r }, undef ) = ::extract_metadata(
3273
3281
(grep (/ ^git-svn-id: / , @log ))[-1]);
@@ -3321,8 +3329,8 @@ sub git_svn_log_cmd {
3321
3329
last ;
3322
3330
}
3323
3331
3324
- my $url = ( ::working_head_info($head ))[0] ;
3325
- my $gs = Git::SVN -> find_by_url( $url ) || Git::SVN-> _new;
3332
+ my ( $url , $rev , $uuid , $gs ) = ::working_head_info($head );
3333
+ $gs ||= Git::SVN-> _new;
3326
3334
my @cmd = (qw/ log --abbrev-commit --pretty=raw --default/ ,
3327
3335
$gs -> refname);
3328
3336
push @cmd , ' -r' unless $non_recursive ;
0 commit comments