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

[StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>

From
Onno Kortmann <onno@gmx.net>
Date
Feb 17, 2008, 21:03 UTC
Message-ID
<200802172203.55533.onno@gmx.net>

instead of stg rename <old> <new>. This is for example helpful for those people who always have a typo or two in their patch names. ---

 stgit/commands/rename.py |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index e2b0fa4..acdf962 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -25,9 +25,10 @@ from stgit import stack, git
 
 
 help = 'rename a patch in the series'
-usage = """%prog [options] <oldpatch> <newpatch>
+usage = """%prog [options] [oldpatch] <newpatch>
 
-Rename <oldpatch> into <newpatch> in a series."""
+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given, 
the
+top-most patch will be renamed. """
 
 directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
@@ -37,9 +38,18 @@ options = [make_option('-b', '--branch',
 def func(parser, options, args):
     """Rename a patch in the series
     """
-    if len(args) != 2:
-        parser.error('incorrect number of arguments')
+    crt=crt_series.get_current()
+
+    if len(args) == 2:
+        out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
+
+    elif len(args) == 1:
+        if not crt:
+            raise CmdException, "No applied top patch to rename exists."
+        args=[crt]+args
+        out.start('Renaming top-most patch "%s" to "%s"' % (args[0], 
args[1]))
+    
+    else: parser.error('incorrect number of arguments')
 
-    out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
     crt_series.rename_patch(args[0], args[1])
     out.done()
Next: Karl Hasselström
Message 1 of 10 in “Allow renaming of the top-most branch by just calling stg rename <new-patch-name>”
  1. Allow renaming of the top-most branch by just calling stg rename <new-patch-name>Onno Kortmann, Feb 17, 2008
  2. Karl HasselströmFeb 18, 2008
  3. Onno KortmannFeb 21, 2008
  4. Karl HasselströmFeb 22, 2008
  5. Onno KortmannFeb 22, 2008
  6. Karl HasselströmFeb 23, 2008
  7. 1/2 Simple rename of top-most patchOnno Kortmann, Feb 21, 2008
  8. Karl HasselströmFeb 22, 2008
  9. 2/2 Test the 'stg rename' commandOnno Kortmann, Feb 21, 2008
  10. Karl HasselströmFeb 22, 2008

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.