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

[StGIT PATCH 3/6] Add -O flag to stg-fold-files-from.

From
Yann Dirson <ydirson@altern.org>
Date
Aug 2, 2007, 20:18 UTC
Message-ID
<20070802201826.16614.19867.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070802200704.16614.57993.stgit@gandelf.nowhere.earth>
From: Yann Dirson <yann.dirson@sagem.com>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-fold-files-from |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from
index 53d3d02..806a157 100755
--- a/contrib/stg-fold-files-from
+++ b/contrib/stg-fold-files-from
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 set -e
 
 # stg-fold-files-from - picks changes to one file from another patch.
@@ -6,8 +6,9 @@ set -e
 # 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>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-fold-files-from <patch> [-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.
@@ -18,14 +19,17 @@ shift
 filtercmd=cat
 hunks=
 foldflags=
+showflags=()
 while [ "$#" -gt 0 ]; do
     case "$1" in
-	-\#*) hunks="$1"; shift ;;
-	-t) foldflags="-t"; shift ;;
+	-\#*) hunks="$1" ;;
+	-t) foldflags="-t" ;;
+	-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; }
 
-stg show "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags
+stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags
Previous: Yann DirsonNext: Yann Dirson
Message 4 of 8 in “Various contrib/ updates”
  1. 0/6 Various contrib/ updatesYann Dirson, Aug 2, 2007
  2. 1/6 Improve stg-fold-files-from doc.Yann Dirson, Aug 2, 2007
  3. 2/6 New contrib scripts: stg-dispatch and stg-show.Yann Dirson, Aug 2, 2007
  4. 3/6 Add -O flag to stg-fold-files-from.Yann Dirson, Aug 2, 2007
  5. 4/6 Add a no-act flag to stg-dispatch and stg-fold-file-from.Yann Dirson, Aug 2, 2007
  6. 5/6 Provide file completion for add/resolved/refresh based on status.Yann Dirson, Aug 2, 2007
  7. 6/6 Fixed completion function hardcoding .git/.Yann Dirson, Aug 2, 2007
  8. Catalin MarinasAug 20, 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.