Skip to content

Commit 17a10f3

Browse files
Eric WongJunio C Hamano
authored andcommitted
git-svn: correctly kill keyword expansion without munging EOLs
This bugfix applies to users of the svn command-line client only. We no longer muck with newlines when killing keyword expansion. This tended to generate unintended diffs in commits because svn revert -R would destroy the manual EOL changes we were doing. Of course, we didn't need the EOL munging in the first place, as svn seems to do it for us even in the text-base files. Now we set the mtime and atime the files changed by keyword expansion killing to avoid triggering a change on svn revert, which svn still seems to want to do. Thanks to Seth Falcon for reporting this bug. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 5bb1cda commit 17a10f3

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

git-svn.perl

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use File::Path qw/mkpath/;
3232
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev pass_through/;
3333
use File::Spec qw//;
34+
use File::Copy qw/copy/;
3435
use POSIX qw/strftime/;
3536
use IPC::Open3;
3637
use Memoize;
@@ -77,9 +78,6 @@
7778
'copy-similarity|C=i'=> \$_cp_similarity
7879
);
7980

80-
# yes, 'native' sets "\n". Patches to fix this for non-*nix systems welcome:
81-
my %EOL = ( CR => "\015", LF => "\012", CRLF => "\015\012", native => "\012" );
82-
8381
my %cmd = (
8482
fetch => [ \&fetch, "Download new revisions from SVN",
8583
{ 'revision|r=s' => \$_revision, %fc_opts } ],
@@ -1760,43 +1758,6 @@ sub svn_info {
17601758

17611759
sub sys { system(@_) == 0 or croak $? }
17621760

1763-
sub eol_cp {
1764-
my ($from, $to) = @_;
1765-
my $es = svn_propget_base('svn:eol-style', $to);
1766-
open my $rfd, '<', $from or croak $!;
1767-
binmode $rfd or croak $!;
1768-
open my $wfd, '>', $to or croak $!;
1769-
binmode $wfd or croak $!;
1770-
eol_cp_fd($rfd, $wfd, $es);
1771-
close $rfd or croak $!;
1772-
close $wfd or croak $!;
1773-
}
1774-
1775-
sub eol_cp_fd {
1776-
my ($rfd, $wfd, $es) = @_;
1777-
my $eol = defined $es ? $EOL{$es} : undef;
1778-
my $buf;
1779-
use bytes;
1780-
while (1) {
1781-
my ($r, $w, $t);
1782-
defined($r = sysread($rfd, $buf, 4096)) or croak $!;
1783-
return unless $r;
1784-
if ($eol) {
1785-
if ($buf =~ /\015$/) {
1786-
my $c;
1787-
defined($r = sysread($rfd,$c,1)) or croak $!;
1788-
$buf .= $c if $r > 0;
1789-
}
1790-
$buf =~ s/(?:\015\012|\015|\012)/$eol/gs;
1791-
$r = length($buf);
1792-
}
1793-
for ($w = 0; $w < $r; $w += $t) {
1794-
$t = syswrite($wfd, $buf, $r - $w, $w) or croak $!;
1795-
}
1796-
}
1797-
no bytes;
1798-
}
1799-
18001761
sub do_update_index {
18011762
my ($z_cmd, $cmd, $no_text_base) = @_;
18021763

@@ -1824,9 +1785,11 @@ sub do_update_index {
18241785
'text-base',"$f.svn-base");
18251786
$tb =~ s#^/##;
18261787
}
1788+
my @s = stat($x);
18271789
unlink $x or croak $!;
1828-
eol_cp($tb, $x);
1790+
copy($tb, $x);
18291791
chmod(($mode &~ umask), $x) or croak $!;
1792+
utime $s[8], $s[9], $x;
18301793
}
18311794
print $ui $x,"\0";
18321795
}

0 commit comments

Comments
 (0)