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} \"\...@\"
-    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 "${allop...@]}"; 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} \"\...@\"
+    unset args
+fi
+
: ${QUILT_SERIES:=series}

if [ "${QUILT_SERIES:0:1}" = / ]





_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to