Skip to content

Commit 86416c6

Browse files
author
jef
committed
add fixdiff.pl to convert svn diff from other architectures
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8395 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fe02fa2 commit 86416c6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

scripts/fixdiff.pl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/perl
2+
3+
# NAME
4+
# fixdiff.pl - fix line endings in svn diff to match lineending of existing files
5+
# SYNOPSIS
6+
# perl fixdiff.pl a.diff | patch -p0 ...
7+
# DESCRIPTION:
8+
# parse diff and modify the hunks to match the line ending of the target files
9+
# This is useful, when the compared trees to generate the diff are on a
10+
# different architecture than that of the one where the patch is to be
11+
# applied.
12+
# LICENSE:
13+
# Copyright 2008 Jürgen E. Fischer <jef@norbit.de>
14+
# GPL2
15+
16+
use strict;
17+
use warnings;
18+
19+
my $dos;
20+
21+
while(<>) {
22+
if( /^Index: (.*)\n/ ) {
23+
my $file=$1;
24+
$dos=0;
25+
26+
if(-f $file) {
27+
open F, $file;
28+
binmode(F);
29+
$dos=1 if scalar(<F>) =~ /\r\n$/;
30+
close F;
31+
32+
#warn "$file in DOS mode!" if $dos;
33+
} else {
34+
warn "$file not found.";
35+
}
36+
} elsif(/^$/) {
37+
# skip empty lines
38+
next;
39+
} elsif(/^===================================================================/ ||
40+
/^---/ ||
41+
/^\+\+\+/ ||
42+
/^@@/) {
43+
print;
44+
} elsif($dos && !/\r\n$/) {
45+
chop;
46+
print "$_\r\n";
47+
} elsif(!$dos && /\r\n$/) {
48+
chop;
49+
chop;
50+
print "$_\n";
51+
} else {
52+
print;
53+
}
54+
}

0 commit comments

Comments
 (0)