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