From: Yann Dirson Date: Mon, 20 Aug 2007 21:35:59 +0000 (+0100) Subject: Add a no-act flag to stg-dispatch and stg-fold-file-from. X-Git-Tag: v0.14.3~168 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/cbb3c5531fd624a35c48c6b5056597143ad55695?ds=sidebyside Add a no-act flag to stg-dispatch and stg-fold-file-from. Signed-off-by: Yann Dirson --- diff --git a/contrib/stg-dispatch b/contrib/stg-dispatch index 8911946..e9cfb05 100755 --- a/contrib/stg-dispatch +++ b/contrib/stg-dispatch @@ -6,7 +6,7 @@ set -e # do so), but from the patch containing the changes to migrate, # instead of doing so from the target patch. -# usage: stg-dispatch [-#[-][,]...] +# usage: stg-dispatch [-n] [-#[-][,]...] # Copyright (c) 2007 Yann Dirson # Subject to the GNU GPL, version 2. @@ -17,6 +17,12 @@ die() exit 1 } +noact=0 +if [ "x$1" = "x-n" ]; then + noact=1 + shift +fi + TOPATCH="$1" shift @@ -28,7 +34,11 @@ CURRENTPATCH=$(stg top) [ "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 diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from index 806a157..c52abfc 100755 --- a/contrib/stg-fold-files-from +++ b/contrib/stg-fold-files-from @@ -8,7 +8,7 @@ set -e # identify hunk numbers easily. # Use "-O -U" to get finer hunk granularity for -#. -# usage: stg-fold-files-from [-O ] [-#[-][,]...] +# usage: stg-fold-files-from [-n] [-O ] [-#[-][,]...] # Copyright (c) 2006-2007 Yann Dirson # Subject to the GNU GPL, version 2. @@ -20,10 +20,12 @@ filtercmd=cat 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 ;; @@ -32,4 +34,13 @@ while [ "$#" -gt 0 ]; do 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