From ed239fbd9baf26fe26349fd115523156bac58a37 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 2 Mar 2007 21:34:28 +0000 Subject: [PATCH] Add contrib/stg-fold-files-from: pick selected changes from a patch above current one Signed-off-by: Yann Dirson --- contrib/stg-fold-files-from | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 contrib/stg-fold-files-from diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from new file mode 100755 index 0000000..bfb4a1f --- /dev/null +++ b/contrib/stg-fold-files-from @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +# stg-fold-files-from - picks changes to one file from another patch. +# Only supports picking from one file, but allows to select any range +# of hunks from the file, using the -# flag to filterdiff. +# Use together with "filterdiff --annotate" in your diff pager, to +# identify hunk numbers easily. + +# usage: stg-fold-files-from [-#[-][,]...] + +# Copyright (c) 2006-2007 Yann Dirson +# Subject to the GNU GPL, version 2. + +PATCH="$1" +shift + +filtercmd=cat +hunks= +foldflags= +while [ "$#" -gt 0 ]; do + case "$1" in + -\#*) hunks="$1"; shift ;; + -t) foldflags="-t"; shift ;; + -*) { echo >&2 "unknown flag '$1'"; exit 1; } ;; + *) break ;; + esac +done +[ "$#" = 1 ] || { echo >&2 "supports one file only"; exit 1; } + +stg show "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags -- 2.11.0