# $ cd $FG_ROOT/Aircraft/foo
# $ fg-submit # generates foo.tar.bz2 and foo.diff
#
-# The archive contains a copy of the diff, which is only left for
-# convenience and doesn't have to be submitted.
+# The archive contains a copy of the diff, so the extra diff file
+# shouldn't be sumitted. It's only left for convenience.
SELF=$(basename $0)
AIRCRAFT=$(basename $PWD)
function diffstat {
# output diff statistics, similar to the "diffstat" utility
awk '
- function out() {
+ function dofile() {
+ if (!file) {
+ return;
+ }
if (bin) {
print "\t\tbinary\t\t"file;
} else {
print "\t+"a"\t-"r"\t!"c"\t"file
+ at += a; rt += r; ct += c;
}
+ a = r = c = 0;
}
BEGIN {
print "\tadded___removed_changed___________________________________";
a = r = c = at = rt = ct = n = bin = 0;
}
- /^Index: / { if (file) { out() } a = r = c = scan = bin = 0; file = $2; n += 1 }
- /^@@/ { scan = 1 }
- /^Binary/ { if (!scan) { bin = 1 } }
- /^+/ { if (scan) { a += 1; at += 1 } }
- /^-/ { if (scan) { r += 1; rt += 1 } }
- /^!/ { if (scan) { c += 1; ct += 1 } }
+ /^Index: / { dofile(); scan = bin = 0; file = $2; n += 1; next }
+ /^@@/ { scan = 1; next }
+ /^Binary/ { if (!scan) { bin = 1 } next }
+ /^+/ { if (scan) { a += 1 } next }
+ /^-/ { if (scan) { r += 1 } next }
+ /^!/ { if (scan) { c += 1 } next }
END {
- if (file) { out() }
+ dofile();
print "\t-----------------------------------total------------------";
print "\t+"at"\t-"rt"\t!"ct"\tin "n" files"
}
diffstat $DIFF
# add diff file itself
- echo $DIFF >> $TMP/include
+ echo $DIFF >>$TMP/include
# add changed binary files
awk '
/^Index: / { scan = 1; file = $2 }
/^@@/ { scan = 0 }
/^Binary/ { if (scan) { print file } }
- ' < $DIFF >>$TMP/include
+ ' <$DIFF >>$TMP/include
else
rm -f $DIFF
fi
if [ -f $TMP/include ]; then
cat $TMP/include|while read i; do
ADD "$i"
- echo $i >> $TMP/files
+ echo $i >>$TMP/files
done
fi
grep "^? " $TMP/up|while read i; do
- FILE=${i#? }
- find $FILE -type f >> $TMP/files
+ find ${i#? } -type f >>$TMP/files
done
# classify and filter files
if [ -f $TMP/files ]; then
- for FILE in $(cat $TMP/files); do
- case "$FILE" in
+ for i in $(cat $TMP/files); do
+ case "$i" in
$ARCHIVE*|$DIFF*) # don't add files generated by the script
;;
*/.*|.*) # silently drop hidden files
;;
- *~|*.bak|*.orig|*..)
- REJECT "$FILE\t\t(backup file)"
+ *~|*.|*.bak|*.orig)
+ REJECT "$i\t\t(backup file)"
;;
- *CVS/*)
- REJECT "$FILE\t\t(CVS file)"
+ CVS/*|*/CVS/*)
+ REJECT "$i\t\t(CVS file)"
;;
*.blend|*.blend[0-9]|*.blend[0-9][0-9])
- REJECT "$FILE\t\t(blender file)"
+ REJECT "$i\t\t(blender file)"
;;
*.xcf|*.tga|*.bmp|*.BMP|*.png)
- REJECT "$FILE\t\t(graphics file)"
+ REJECT "$i\t\t(graphics file)"
;;
*)
- ADD "$FILE"
- echo "$FILE" >> $TMP/include
+ ADD "$i"
+ echo "$i" >>$TMP/include
;;
esac
done
LOG "creating archive $ARCHIVE"
tar -cjf $ARCHIVE --files-from $TMP/include
else
- LOG "no changes or new files detected"
+ LOG "no changed or new files detected"
fi
exit 0