summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2015-06-25 15:20:14 +0200
committerYvan Roux <yvan.roux@linaro.org>2015-06-25 15:20:14 +0200
commit281b5e32fe28cb0c8a435d4ee3a86633b9aa1f5a (patch)
tree37ee6f745db708c217812b0a2261469319e848e5
parentf02fd5497f2b2adc2246700f1627191d4e4565fc (diff)
Move temporary and log files outside of the repo.
Change-Id: I70d391ee6f2c11298eb49601c10680feea97b6fc
-rwxr-xr-xbackflip40
1 files changed, 20 insertions, 20 deletions
diff --git a/backflip b/backflip
index dea9a78..e4ceb44 100755
--- a/backflip
+++ b/backflip
@@ -21,6 +21,7 @@ STACKED=false
CMPTOOL="meld"
INTERACTIVE=true
COLOR=true
+TMPDIR=/tmp/$(basename "$0")-$$
# Arguments
while getopts "b:r:v:x" options
@@ -42,8 +43,7 @@ done
shift $(($OPTIND - 1))
REV=$1
-commitfile=./backport-${REV}.msg
-logfile=./backport-${REV}.log
+PREFIX=${TMPDIR}/backport-${REV}
if [ -z ${DEV_BRANCH+x} ]; then
DEV_BRANCH=${REF_BRANCH}
@@ -91,38 +91,37 @@ ask() {
# arg2 : ChangeLog file
# Create ChangeLog entry for arg1 in arg2.arg1.frag
forge_entry() {
- echo -e "\tBackport from trunk r$1." > $2.$1.frag
+ FRAGFILE=${TMPDIR}/$(echo $2 | sed "s:/:-:g")-$1.frag
+ echo -e "\t"`dirname $2`/ >> ${PREFIX}.msg
+ echo -e "\tBackport from trunk r$1." >> ${PREFIX}.msg
git show --format=oneline ${SHA1} -- $2 \
| grep ^+ \
| sed -e '1d' -e 's:^+::' \
- | awk '$1 ~ /^2.*$/ {print "\t"$0} $1 !~ /^2.*$/ {print $0}' >> $2.$1.frag
+ | awk '$1 ~ /^2.*$/ {print "\t"$0} $1 !~ /^2.*$/ {print $0}' > $FRAGFILE
print_info "${bold}Forged ChangeLog entry:${NC}"
- cat $2.$1.frag
+ cat $FRAGFILE
if $INTERACTIVE; then
ask "${bold}Edit ChangeLog entry [N/y] ?" user_edit
if [ "$user_edit" == "y" ]; then
- "$EDITOR" $2.$1.frag
+ "$EDITOR" $FRAGFILE
fi
fi
- cat $2.$REV.frag >> ${commitfile}
+ cat $FRAGFILE >> ${PREFIX}.msg
}
# arg1 : backported revision sha1
compare() {
- git show $1 > $REV.orig
- git diff --cached > $REV.linaro
+ git show $1 > ${TMPDIR}/$REV.orig
+ git diff --cached > ${TMPDIR}/$REV.linaro
print_info "Generated diff files: ${bold}$REV.orig $REV.linaro${NC}"
- "$CMPTOOL" $REV.orig $REV.linaro
+ "$CMPTOOL" ${TMPDIR}/$REV.orig ${TMPDIR}/$REV.linaro
ask "${bold}Do you need a Shell [N/y] ?" user_shell
if [ "$user_shell" == "y" ]; then
open_shell
fi
- rm $REV.orig $REV.linaro
}
clean() {
- rm -f ${commitfile}
- find . -type f -name \*.frag -exec rm -f {} \;
git reset --hard
git checkout ${DEV_BRANCH}
exit $1
@@ -148,8 +147,10 @@ if ! which $CMPTOOL > /dev/null ; then
ask "Enter tool name: " CMPTOOL
fi
+mkdir $TMPDIR
+
if ! $INTERACTIVE; then
- exec >${logfile} 2>&1
+ exec >${PREFIX}.log 2>&1
fi
echo -e "${blue}${lines}"
@@ -190,7 +191,6 @@ for i in $CHLOGS; do
git reset -q HEAD $i
git checkout $i
# Create ChangeLog entry
- echo `dirname $i`/ >> ${commitfile}
forge_entry $1 $i
done
@@ -204,8 +204,8 @@ if $INTERACTIVE; then
open_shell
fi
else
- git status --porcelain | grep "^UU" && \
- { mv ${logfile} ${logfile}.ko; clean 1; }
+ git status --porcelain | grep "^.U" && \
+ { mv ${PREFIX}.log ${PREFIX}-ko.log; clean 1; }
fi
# ==============================================================================
@@ -238,9 +238,9 @@ if $INTERACTIVE; then
ask "${bold}Commit backport [Y/n] ?" user_commit
if [ "$user_commit" != "n" ]; then
if $STACKED; then
- git commit --amend
+ git commit --amend -F ${PREFIX}.msg
else
- git commit -F ${commitfile}
+ git commit -F ${PREFIX}.msg
fi
echo
@@ -264,7 +264,7 @@ else
print_info "Create backport branch."
git checkout -b ${bname} ${DEV_BRANCH}
print_info "Commit backport."
- git commit -F ${commitfile}
+ git commit -F ${PREFIX}.msg
print_info "Request review."
git review $REF_BRANCH
fi