Skip to content

Commit d39d10d

Browse files
author
Junio C Hamano
committed
Merge branch 'maint'
* maint: Add Documentation/cmd-list.made to .gitignore git-svn: fix log command to avoid infinite loop on long commit messages git-svn: dcommit/rebase confused by patches with git-svn-id: lines git-svn: bail out on incorrect command-line options
2 parents 8d1608b + 24c64d6 commit d39d10d

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

Documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.html
33
*.1
44
*.7
5+
*.made
56
howto-index.txt
67
doc.dep
78
cmds-*.txt

git-svn.perl

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,12 @@ sub cmd_dcommit {
363363
my $head = shift;
364364
$head ||= 'HEAD';
365365
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) {
369368
die "Unable to determine upstream SVN information from ",
370369
"$head history\n";
371370
}
372-
my $gs = Git::SVN->find_by_url($url);
371+
my $c = $refs[-1];
373372
my $last_rev;
374373
foreach my $d (@refs) {
375374
if (!verify_ref("$d~1")) {
@@ -431,16 +430,11 @@ sub cmd_dcommit {
431430

432431
sub cmd_rebase {
433432
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) {
436435
die "Unable to determine upstream SVN information from ",
437436
"working tree history\n";
438437
}
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-
}
444438
if (command(qw/diff-index HEAD --/)) {
445439
print STDERR "Cannot rebase with uncommited changes:\n";
446440
command_noisy('status');
@@ -453,8 +447,8 @@ sub cmd_rebase {
453447
}
454448

455449
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;
458452
my $r = (defined $_revision ? $_revision : $gs->ra->get_latest_revnum);
459453
$gs->traverse_ignore(\*STDOUT, $gs->{path}, $r);
460454
}
@@ -776,16 +770,23 @@ sub cmt_metadata {
776770

777771
sub working_head_info {
778772
my ($head, $refs) = @_;
779-
my ($url, $rev, $uuid);
780773
my ($fh, $ctx) = command_output_pipe('rev-list', $head);
781774
while (<$fh>) {
782775
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+
}
785786
unshift @$refs, $_ if $refs;
786787
}
787-
close $fh; # break the pipe
788-
($url, $rev, $uuid);
788+
command_close_pipe($fh, $ctx);
789+
(undef, undef, undef, undef);
789790
}
790791

791792
package Git::SVN;
@@ -3262,12 +3263,19 @@ package Git::SVN::Log;
32623263
sub cmt_showable {
32633264
my ($c) = @_;
32643265
return 1 if defined $c->{r};
3266+
3267+
# big commit message got truncated by the 16k pretty buffer in rev-list
32653268
if ($c->{l} && $c->{l}->[-1] eq "...\n" &&
32663269
$c->{a_raw} =~ /\@([a-f\d\-]+)>$/) {
3270+
@{$c->{l}} = ();
32673271
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 '');
32693275
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;
32713279

32723280
(undef, $c->{r}, undef) = ::extract_metadata(
32733281
(grep(/^git-svn-id: /, @log))[-1]);
@@ -3321,8 +3329,8 @@ sub git_svn_log_cmd {
33213329
last;
33223330
}
33233331

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;
33263334
my @cmd = (qw/log --abbrev-commit --pretty=raw --default/,
33273335
$gs->refname);
33283336
push @cmd, '-r' unless $non_recursive;

0 commit comments

Comments
 (0)