diff mbox

[17/16] libxfs-apply: port to stgit

Message ID 20161122182644.GP16813@birch.djwong.org (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong Nov. 22, 2016, 6:26 p.m. UTC
Teach libxfs-apply how to talk to a stgit repository
and fix a minor typo in the guilt hunk of apply_patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tools/libxfs-apply |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tools/libxfs-apply b/tools/libxfs-apply
index 8df1a49..5cf0879 100755
--- a/tools/libxfs-apply
+++ b/tools/libxfs-apply
@@ -66,6 +66,7 @@  PATCH=
 COMMIT_ID=
 VERBOSE=
 GUILT=0
+STGIT=0
 
 while [ $# -gt 0 ]; do
 	case "$1" in
@@ -95,6 +96,12 @@  if [ $? -eq 0 ]; then
 	GUILT=1
 fi
 
+# Are we using stgit? This works even if no patch is applied.
+stg top &> /dev/null
+if [ $? -eq 0 ]; then
+	STGIT=1
+fi
+
 #this is pulled from the guilt code to handle commit ids sanely.
 # usage: munge_hash_range <hash range>
 #
@@ -332,7 +339,27 @@  apply_patch()
 			guilt refresh
 		else
 			echo "Guilt push failed!"
-			read -r -p "Skip of Fail [s|F]? " response
+			read -r -p "Skip or Fail [s|F]? " response
+			if [ -z "$response" -o "$response" != "s" ]; then
+				echo "Force push patch, fix and refresh."
+				echo "Restart from commit $_current_commit"
+				fail "Manual cleanup required!"
+			else
+				echo "Skipping. Manual series file cleanup needed!"
+			fi
+		fi
+	elif [ $STGIT -eq 1 ]; then
+		[ -n "$VERBOSE" ] || echo "$REPO looks like a stgit directory."
+		PATCHES=`stg series | wc -l`
+		if [ -n "$VERBOSE" -a $PATCHES -gt 0 ]; then
+			echo -n "Top patch is: "
+			stg top
+		fi
+
+		stg import -n $_patch_name $_new_patch.2
+		if [ $? -ne 0 ]; then
+			echo "stgit push failed!"
+			read -r -p "Skip or Fail [s|F]? " response
 			if [ -z "$response" -o "$response" != "s" ]; then
 				echo "Force push patch, fix and refresh."
 				echo "Restart from commit $_current_commit"