guilt-fork: Use first argument (if given) as name of new patch
PATCH 1/1 guilt-fork: Use first argument (if given) as name of new patch
From: Eric Lesh <[email protected]>
Date: Tue, 27 Mar 2007 20:28:34 -0700
Subject: [PATCH] guilt-fork: Use first argument (if given) as name of new patch
Signed-off-by Eric Lesh <[email protected]>
--- guilt-fork | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
guilt-fork +15 -6
@@ -3,9 +3,10 @@ # Copyright (c) Josef "Jeff" Sipek, 2007 # +USAGE="[<new_name>]" . guilt -if [ $# -gt 0 ]; then +if [ $# -gt 1 ]; then usage fi
@@ -20,11 +21,19 @@ if ! must_commit_first; then fi # 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}" +if [ $# -eq 1 ]; then + newpatch="$1" +else + 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}" +fi + +if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then + die "Patch \"$newpatch\" already exists. Choose another name." +fi # copy the patch cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"
Signature · 1 line
1.5.1-rc1.GIT