All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Lesh <eclesh@ucla.edu>
To: jsipek@cs.sunysb.edu
Cc: git <git@vger.kernel.org>
Subject: [PATCH guilt] guilt-fork: Use first argument (if given) as name of new patch
Date: Tue, 27 Mar 2007 20:46:16 -0700	[thread overview]
Message-ID: <1175053576.5945.11.camel@localhost> (raw)

From: Eric Lesh <eclesh@ucla.edu>
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 <eclesh@ucla.edu>
---
 guilt-fork |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/guilt-fork b/guilt-fork
index ae31739..426a7e7 100755
--- a/guilt-fork
+++ b/guilt-fork
@@ -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"
-- 
1.5.1-rc1.GIT

                 reply	other threads:[~2007-03-28  3:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1175053576.5945.11.camel@localhost \
    --to=eclesh@ucla.edu \
    --cc=git@vger.kernel.org \
    --cc=jsipek@cs.sunysb.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.