[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [RFC] Conditional diff/refresh opts depending on the source
From: |
Andreas Krebbel |
Subject: |
[Quilt-dev] [RFC] Conditional diff/refresh opts depending on the source dir name |
Date: |
Wed, 20 Jan 2010 11:36:04 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Hi,
working on different projects I've to deal with different patch formats
and was looking for a way to handle that automatically for me.
I'm using quilt for my patch management very much but usually forget
about adjusting the diff options in .quiltrc when switching from one
project to another. That's why I did a small change to my local quilt
installation which allows me to set diff opts depending on the name of
the source directory of the project. With that change it is possible to
set quilt diff args like that:
QUILT_DIFF_ARGS="--no-timestamps --color=auto | gcc*:-C3 | *libc*:-U3"
which makes quilt to use these options when in a directory starting with
gcc:
--no-timestamps --color=auto -C3
or these if you are in a directory whose name contains libc:
--no-timestamps --color=auto -U3
I think this might be useful to others as well. What do you think?
Bye,
-Andreas-
patchfns.in | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 42 insertions(+), 7 deletions(-)
Index: quilt-0.48/quilt/scripts/patchfns.in
===================================================================
--- quilt-0.48.orig/quilt/scripts/patchfns.in
+++ quilt-0.48/quilt/scripts/patchfns.in
@@ -37,13 +37,6 @@ then
source "$QUILTRC"
fi
-# Add default arguments for this command
-if [ -n "$QUILT_COMMAND" ]; then
- args="QUILT_$(echo $QUILT_COMMAND | tr a-z A-Z)_ARGS"
- eval set -- ${!args} \"address@hidden"
- unset args
-fi
-
# ========================================================
#declare -a exit_handlers
@@ -969,6 +962,34 @@ quilt_command()
QUILT_COMMAND="" bash $BASH_OPTS -c "${SUBDIR:+cd $SUBDIR;} .
$QUILT_DIR/$command" "quilt $command" "$@"
}
+expand_conditional_opts()
+{
+ local dir=$1
+ local optstring=$2
+ local outopts=""
+
+ IFS='|' read -ra allopts <<< "$optstring"
+
+ for o in "address@hidden"; do
+ # Strip leading and trailing blanks
+ o=$(echo $o)
+ # If there is no : in the string the options are unconditional
+ if [[ $o != *:* ]]; then
+ outopts+=" "
+ outopts+=$o
+ continue
+ fi
+ local dirpat=${o%%:[^:]*}
+ local opts=${o##[^:]*:}
+
+ if [[ $dir == $dirpat ]]; then
+ outopts+=" "
+ outopts+=$opts
+ fi
+ done
+ echo ${outopts}
+}
+
#
# If the working directory does not contain a $QUILT_PATCHES directory,
# quilt searches for its base directory up the directory tree. If no
@@ -1005,6 +1026,20 @@ then
unset basedir down
fi
+SRCDIR=$(basename $PWD)
+
+QUILT_DIFF_ARGS=$(expand_conditional_opts "${SRCDIR}" "${QUILT_DIFF_ARGS}")
+QUILT_REFRESH_ARGS=$(expand_conditional_opts "${SRCDIR}"
"${QUILT_REFRESH_ARGS}")
+
+unset SRCDIR
+
+# Add default arguments for this command
+if [ -n "$QUILT_COMMAND" ]; then
+ args="QUILT_$(echo $QUILT_COMMAND | tr a-z A-Z)_ARGS"
+ eval set -- ${!args} \"address@hidden"
+ unset args
+fi
+
: ${QUILT_SERIES:=series}
if [ "${QUILT_SERIES:0:1}" = / ]
- [Quilt-dev] [RFC] Conditional diff/refresh opts depending on the source dir name,
Andreas Krebbel <=