* updated ktuberling (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / scripts / Create-Diff
blobdee683fd3d76881b3f63e88bbdf84589535d5acf
1 #!/bin/bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 #
6 # T2 SDE: scripts/Create-Diff
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 directories="misc package architecture target scripts"
20 if [ "$1" = "-editor" ]; then
21 editor="$2"; shift; shift
24 if [ "$#" -lt 2 ]; then
25 echo; echo " Usage: $0 [ -editor <editor> ] <old-dir> <new-dir> [ {file|directory} ]"
26 echo
27 echo " Creates a unified diff over two T2 source trees. You can"
28 echo " send this diff to the mailing list if you want your changes"
29 echo " to be included."
30 echo
31 echo " Please do create seperate diffs for changes which do not"
32 echo " belong to each other."
33 echo; exit 1
34 else
35 olddir=$1; shift
36 newdir=$1; shift
37 [ "$1" ] && directories="$*"
40 if ! perl -e 'exit 0'; then
41 perl() { cat; }
44 eval "`grep -A 10 '\[BEGIN\]' $olddir/scripts/parse-config | grep -B 10 '\[END\]'`"
46 [ "$editor" = "" ] && echo "[ Generated by scripts/Create-Diff for T2 $sdever ]" > /tmp/$$
48 for x in $directories; do
49 x=${x#./}; x=${x%/}
50 if [ -d $x ]; then
51 FLAGS="-rduN"
52 name_for_diff="$x/."
53 source_for_sed="$x/./"
54 target_for_sed="$x/"
55 else
56 FLAGS="-duN"
57 name_for_diff="$x"
58 source_for_sed=""
59 target_for_sed=""
61 diff -x CVS -x '.svn' -x '.#*' -x '*.mine' -x '*.r[1-9][0-9]*' \
62 $FLAGS "$olddir"/$name_for_diff "$newdir"/$name_for_diff | grep -v '^diff ' | \
63 sed "s,^--- $olddir/$source_for_sed,--- ./$target_for_sed," | \
64 sed "s,^+++ $newdir/$source_for_sed,+++ ./$target_for_sed," | \
65 perl -pe '$fn=$1 if /^--- \.\/(\S+)\s/;
66 $_="" if $fn =~ /~$/'
67 done >> /tmp/$$
69 if [ "$editor" = "" ]; then
70 cat /tmp/$$
71 rm /tmp/$$
72 else
73 eval "$editor /tmp/$$"
74 rm /tmp/$$