yeah, yet another patch ... :-]
- fix config file name in $HOME; This didn't match the documentation. (doesn't cost us anything to check ~/.fg-submit first, and then ~/.fg-submitrc) - don't use mktemp for the backup files. Some outdated distributions (Debian) come with a version that mandates six X, which is just too ugly. Just find the first free slot with sequential number. That isn't thread safe, but mktemp isn't either, so ... (Should be using "lockfile", but its availability on CygWin is questionable. And it's not *that* important.) - some more documentation - some cleanup, too, of course
This commit is contained in:
parent
abc3b3ffa1
commit
5b683d1c8b
1 changed files with 42 additions and 16 deletions
|
@ -100,9 +100,19 @@
|
||||||
# IGNORE *.old # throw out the old files (and don't report
|
# IGNORE *.old # throw out the old files (and don't report
|
||||||
# # that to the terminal)
|
# # that to the terminal)
|
||||||
#
|
#
|
||||||
# .fg-submit configuration files are sourced bash scripts, the
|
#
|
||||||
|
# .fg-submit configuration files are "sourced" bash scripts, the
|
||||||
# keywords are simple shell functions. That means that you can
|
# keywords are simple shell functions. That means that you can
|
||||||
# also use other bash commands in that file, such as "echo".
|
# also use other bash commands in that file, such as "echo", or
|
||||||
|
# write several commands on one line, separated with semicolon.
|
||||||
|
# You can even put all special rules in your ~/.fg-submit file,
|
||||||
|
# with rules depending on the working directory:
|
||||||
|
#
|
||||||
|
# case "$PWD" in
|
||||||
|
# */bo105*) DENY *.osg; ALLOW livery.xcf ;;
|
||||||
|
# */ufo*) DENY *.tiff ;;
|
||||||
|
# esac
|
||||||
|
# DEFAULT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,6 +131,7 @@ CVS=/usr/bin/cvs # avoid colorcvs wrapper from
|
||||||
[ -x $CVS ] || CVS=cvs # http://www.hakubi.us/colorcvs/
|
[ -x $CVS ] || CVS=cvs # http://www.hakubi.us/colorcvs/
|
||||||
UPLOAD=$(which fg-upload 2>/dev/null)
|
UPLOAD=$(which fg-upload 2>/dev/null)
|
||||||
|
|
||||||
|
CONFIG_FILE=".fg-submit"
|
||||||
ARCHIVE=$BASE.tar.bz2
|
ARCHIVE=$BASE.tar.bz2
|
||||||
DIFF=$BASE.diff
|
DIFF=$BASE.diff
|
||||||
CDIFF=$DIFF.bz2
|
CDIFF=$DIFF.bz2
|
||||||
|
@ -140,9 +151,8 @@ DEFAULT_RULES="
|
||||||
-*.blend -*.blend[0-9] -*blend[0-9][0-9] -*.blend[0-9][0-9][0-9]
|
-*.blend -*.blend[0-9] -*blend[0-9][0-9] -*.blend[0-9][0-9][0-9]
|
||||||
-*.gz -*.tgz -*.bz2 -*.zip -*.tar.gz* -*.tar.bz2*
|
-*.gz -*.tgz -*.bz2 -*.zip -*.tar.gz* -*.tar.bz2*
|
||||||
"
|
"
|
||||||
# these rules are always appended; the last one accepts anything
|
# these rules are always appended: ignore all hidden files that
|
||||||
# (throw out all hidden files that weren't explicitly allowed, and
|
# weren't explicitly allowed so far, and accept all the rest
|
||||||
# accept the rest)
|
|
||||||
POSTFIX_RULES="
|
POSTFIX_RULES="
|
||||||
!.* !*/.*
|
!.* !*/.*
|
||||||
+*
|
+*
|
||||||
|
@ -192,6 +202,19 @@ function diffstat {
|
||||||
' <$1
|
' <$1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function backup_filename {
|
||||||
|
i=1
|
||||||
|
while true; do
|
||||||
|
name=$1.$i
|
||||||
|
if ! [ -a "$name" ]; then
|
||||||
|
touch $name
|
||||||
|
echo $name
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
i=$(($i + 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# set up accept/reject rules
|
# set up accept/reject rules
|
||||||
function DEFAULT { RULES="$RULES $DEFAULT_RULES"; }
|
function DEFAULT { RULES="$RULES $DEFAULT_RULES"; }
|
||||||
|
@ -202,8 +225,8 @@ function IGNORE { for i in $*; do RULES="$RULES !$i"; done }
|
||||||
RULES=
|
RULES=
|
||||||
HERE=$PWD
|
HERE=$PWD
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f .fg-submit ]; then
|
if [ -f $CONFIG_FILE ]; then
|
||||||
CONFIG="$PWD/.fg-submit"
|
CONFIG="$PWD/$CONFIG_FILE"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
|
@ -214,9 +237,12 @@ cd "$HERE"
|
||||||
if [ "$CONFIG" ]; then
|
if [ "$CONFIG" ]; then
|
||||||
DEBUG "reading config $CONFIG"
|
DEBUG "reading config $CONFIG"
|
||||||
source "$CONFIG"
|
source "$CONFIG"
|
||||||
elif [ -f ~/.fg-submitrc ]; then
|
elif [ -f ~/$CONFIG_FILE ]; then
|
||||||
DEBUG "reading config ~/.fg-submitrc"
|
DEBUG "reading config ~/$CONFIG_FILE"
|
||||||
source ~/.fg-submitrc
|
source ~/$CONFIG_FILE
|
||||||
|
elif [ -f ~/${CONFIG_FILE}rc ]; then
|
||||||
|
DEBUG "reading config ~/${CONFIG_FILE}rc"
|
||||||
|
source ~/$CONFIG_FILE
|
||||||
else
|
else
|
||||||
DEBUG "no config file found; using default rules"
|
DEBUG "no config file found; using default rules"
|
||||||
RULES="$RULES $DEFAULT_RULES"
|
RULES="$RULES $DEFAULT_RULES"
|
||||||
|
@ -230,9 +256,9 @@ TMP=$(mktemp -d /tmp/$SELF.$BASE.XXXXXX) || (echo "$0: can't create temporary di
|
||||||
trap "rm -rf $TMP" 0 1 2 3 13 15
|
trap "rm -rf $TMP" 0 1 2 3 13 15
|
||||||
|
|
||||||
|
|
||||||
# move old files out of the way
|
# move old files out of the way giving sequential suffixes
|
||||||
for i in $DIFF $CDIFF $ARCHIVE; do
|
for i in $DIFF $CDIFF $ARCHIVE; do
|
||||||
[ -f $i ] && mv $i $(mktemp $i.XXXXXX)
|
[ -f $i ] && mv $i $(backup_filename $i)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,7 +305,7 @@ grep "^? " $TMP/up|while read i; do
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# classify and filter files
|
# filter files according to the pattern rules
|
||||||
if [ -f $TMP/check ]; then
|
if [ -f $TMP/check ]; then
|
||||||
for i in $(cat $TMP/check); do
|
for i in $(cat $TMP/check); do
|
||||||
DEBUG "checking whether file '$i' matches"
|
DEBUG "checking whether file '$i' matches"
|
||||||
|
@ -287,17 +313,17 @@ if [ -f $TMP/check ]; then
|
||||||
DEBUG "\t\trule $r"
|
DEBUG "\t\trule $r"
|
||||||
R=${r#?}
|
R=${r#?}
|
||||||
case "!$i" in $r)
|
case "!$i" in $r)
|
||||||
DEBUG "\t\t\t\"silently\" rejected\t\t(rule $R)"
|
DEBUG "\t\t\t\"silently\" rejected\t\t$R"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
case "-$i" in $r)
|
case "-$i" in $r)
|
||||||
REJECT "$i\t\t(rule $R)"
|
REJECT "$i\t\t$R"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
case "+$i" in $r)
|
case "+$i" in $r)
|
||||||
NEW "$i\t\t(rule $R)"
|
NEW "$i\t\t$R"
|
||||||
echo "$i" >>$TMP/files
|
echo "$i" >>$TMP/files
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue