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

[PATCH] Make "guilt push" match "quilt push" when the patch doesn't apply

From
Theodore Ts'o <tytso@mit.edu>
Date
Feb 26, 2007, 03:58 UTC
Message-ID
<E1HLX7O-0004bu-Qx@candygram.thunk.org>

Sometimes the reason why the patch doesn't apply is because it has already been applied in mainline when rebasing a patch series. It is therefore more convenient if "guilt push" leaves the working tree untouched if the patch fails to apply unless explicitly asked to force apply a failing patch using the -f option.

This behavior matches how "quilt push" and "hg qpush" works, so it also avoids unpleasant surprises for developers used to other patch series tools.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 guilt      |   14 ++++++++++++--
 guilt-push |   16 +++++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/guilt b/guilt
index 284f9fb..f5a55ff 100755
--- a/guilt
+++ b/guilt
@@ -259,8 +259,10 @@ function push_patch
 {
 	local p="$GUILT_DIR/$branch/$1"
 	local pname="$1"
+	local bail_action="$2"
 
 	local bail=0
+	local reject="--reject"
 
 	assert_head_check
 
@@ -268,11 +270,19 @@ function push_patch
 
 	# apply the patch if and only if there is something to apply
 	if [ `git-apply --numstat $p | wc -l` -gt 0 ]; then
+		if [ "$bail_action" = abort ]; then
+		    reject=""
+		fi
 		git-apply -C$guilt_push_diff_context \
-			--reject $p > /dev/null 2> /tmp/guilt.log.$$
+			$reject $p > /dev/null 2> /tmp/guilt.log.$$
 		bail=$?
 
-		[ $bail -ne 0 ] && cat /tmp/guilt.log.$$ >&2
+		if [ $bail -ne 0 ]; then
+			cat /tmp/guilt.log.$$ >&2
+			if [ "$bail_action" = abort ]; then
+				return $bail
+			fi
+		fi
 
 		# FIXME: Path munging is being done, we need to convince
 		# git-apply to just give us list of files with \0 as a
diff --git a/guilt-push b/guilt-push
index 4fb89e2..85b4122 100755
--- a/guilt-push
+++ b/guilt-push
@@ -5,7 +5,14 @@
 
 source "`dirname $0`/guilt"
 
-USAGE="$USAGE [-a | --all | <patchname>]"
+abort_flag="abort"
+
+USAGE="$USAGE [ -f ] [-a | --all | <patchname>]"
+
+if [ "$1" == "-f" ]; then
+	abort_flag=""
+	shift
+fi
 
 if [ $# -gt 1 ]; then
 	print_usage
@@ -61,14 +68,17 @@ for p in `get_series`; do
 		exit 1
 	fi
 
-	push_patch $p
+	push_patch $p $abort_flag
 
 	# bail if necessary
 	if [ $? -eq 0 ]; then
 		echo "Patch applied."
-	else
+	elif [ -z "$abort_flag" ]; then
 		echo "Patch applied with rejects. Fix it up, and refresh." >&2
 		exit 1
+	else
+		echo "To force apply this patch, use 'guilt push -f'" >&2
+		exit 1
 	fi
 done
 
-- 
1.5.0.1.74.g2470
Message 1 of 1 in “Make "guilt push" match "quilt push" when the patch doesn't apply”
  1. Make "guilt push" match "quilt push" when the patch doesn't applyTheodore Ts'o, Feb 26, 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.