/usr/bin/stg-fold-files-from is in stgit-contrib 0.17.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #!/bin/bash
set -e
# stg-fold-files-from - picks changes to one file from another patch.
# Only supports picking from one file pattern, 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.
# Use "-O -U<n>" to get finer hunk granularity for -#<n>.
# 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.
PATCH="$1"
shift
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 ;;
esac
shift
done
[ "$#" = 1 ] || { echo >&2 "supports one file only"; exit 1; }
getpatch()
{
stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1"
}
if [ $noact = 1 ]; then
getpatch "$1"
else
getpatch "$1" | stg fold $foldflags
fi
|