# do so), but from the patch containing the changes to migrate,
# instead of doing so from the target patch.
-# usage: stg-dispatch <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-dispatch [-n] <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
# Subject to the GNU GPL, version 2.
exit 1
}
+noact=0
+if [ "x$1" = "x-n" ]; then
+ noact=1
+ shift
+fi
+
TOPATCH="$1"
shift
[ "x$TOPATCH" != "x$CURRENTPATCH" ] ||
die "dispatching to current patch ($CURRENTPATCH) makes no sense"
-stg goto "$TOPATCH"
-stg-fold-files-from "$CURRENTPATCH" "$@"
-stg refresh
-stg goto "$CURRENTPATCH"
+if [ $noact = 1 ]; then
+ stg-fold-files-from "$CURRENTPATCH" -n "$@"
+else
+ stg goto "$TOPATCH"
+ stg-fold-files-from "$CURRENTPATCH" "$@"
+ stg refresh
+ stg goto "$CURRENTPATCH"
+fi
# identify hunk numbers easily.
# Use "-O -U<n>" to get finer hunk granularity for -#<n>.
-# usage: stg-fold-files-from <patch> [-O <stg-show-flags>] [-#<n>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-fold-files-from <patch> [-n] [-O <stg-show-flags>] [-#<n>[-<n>][,<n>]...] <file-pattern>
# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
# Subject to the GNU GPL, version 2.
hunks=
foldflags=
showflags=()
+noact=0
while [ "$#" -gt 0 ]; do
case "$1" in
-\#*) hunks="$1" ;;
-t) foldflags="-t" ;;
+ -n) noact=1 ;;
-O) showflags+=(-O "$2"); shift ;;
-*) { echo >&2 "unknown flag '$1'"; exit 1; } ;;
*) break ;;
done
[ "$#" = 1 ] || { echo >&2 "supports one file only"; exit 1; }
-stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags
+getpatch()
+{
+ stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1"
+}
+
+if [ $noact = 1 ]; then
+ getpatch "$1"
+else
+ getpatch "$1" | stg fold $foldflags
+fi