Skip to contentSkip to conversation

guilt-fork: Rename patches sequentially (ala quilt)

PATCH New Eric Lesh 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore

Eric Lesh

author
#0 lore raw

PATCH 1/1 guilt-fork: Rename patches sequentially (ala quilt)

From: Eric Lesh <[email protected]>
Date: Tue, 27 Mar 2007 20:18:10 -0700
Subject: [PATCH] guilt-fork: Rename patches sequentially (ala quilt)

---
 guilt-fork |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
guilt-fork +6 -2
index 4ab55d7..ae31739 100755
@@ -19,8 +19,12 @@ if ! must_commit_first; then
 	die "Uncommited changes detected. Refresh first."
 fi
 
-# FIXME: Be smarter about the new patchname (ala what quilt does)
-newpatch="$patch-2"
+# Rename patches smartly
+base=$(echo "$patch" \
+	| sed -r -e 's:(\.diff?|\.patch)$::')
+num=$(echo "$base" | sed -nre 's:.*-([0-9]+)$:\1:'p)
+[ -n "$num" ] || num=1
+newpatch="${base%-$num}-$((num+1))${patch#$base}"
 
 # copy the patch
 cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"
Signature · 1 line
1.5.1-rc1.GIT