git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/5] Add contrib/stg-fold-files-from: pick selected changes from a patch above current one

From
Yann Dirson <ydirson@altern.org>
Date
Jan 4, 2007, 23:46 UTC
Message-ID
<20070104234653.13580.65088.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070104233934.13580.17744.stgit@gandelf.nowhere.earth>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-fold-files-from |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
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 <patch> [-#<n>[-<n>][,<n>]...] <file>
+
+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
+# 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
Previous: Yann DirsonNext: Yann Dirson
Message 4 of 8 in “My set of stgit companion scripts.”
  1. 0/5 My set of stgit companion scripts.Yann Dirson, Jan 4, 2007
  2. 1/5 Add contrib/stg-show-old: show old version of a patch.Yann Dirson, Jan 4, 2007
  3. 2/5 Add contrib/stg-whatchanged: look at what would be changed by refreshing.Yann Dirson, Jan 4, 2007
  4. 3/5 Add contrib/stg-fold-files-from: pick selected changes from a patch above current oneYann Dirson, Jan 4, 2007
  5. 4/5 Add contrib/stg-swallow: completely merge an unapplied patch into current oneYann Dirson, Jan 4, 2007
  6. 5/5 Add contrib/stg-cvs: helper script to manage a mixed cvs/stgit working copyYann Dirson, Jan 4, 2007
  7. Catalin MarinasJan 9, 2007
  8. Yann DirsonJan 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.