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

[PATCH 5/9] Correctly handle refs/patches on series rename

From
Yann Dirson <ydirson@altern.org>
Date
Apr 16, 2006, 10:52 UTC
Message-ID
<20060416105237.9884.44865.stgit@gandelf.nowhere.earth>
In-Reply-To
<20060416104144.9884.28167.stgit@gandelf.nowhere.earth>

When renaming a series, the refs/patches dir was not moved, and by chance a new one was created by the repository-upgrade code, but that left the old one behind as cruft (which the safety checks added in a former patch now detects).

Also adds a regression test to assert that nothing by the old name is left behind.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 stgit/stack.py           |    2 ++
 t/t1001-branch-rename.sh |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
index 19bb62a..975ac21 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -505,6 +505,8 @@ class Series:
             os.rename(self.__series_dir, to_stack.__series_dir)
         if os.path.exists(self.__base_file):
             os.rename(self.__base_file, to_stack.__base_file)
+        if os.path.exists(self.__refs_dir):
+            os.rename(self.__refs_dir, to_stack.__refs_dir)
 
         self.__init__(to_name)
 
diff --git a/t/t1001-branch-rename.sh b/t/t1001-branch-rename.sh
new file mode 100755
index 0000000..28da15c
--- /dev/null
+++ b/t/t1001-branch-rename.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Yann Dirson
+#
+
+test_description='Branch renames.
+
+Exercises branch renaming commands.
+'
+
+. ./test-lib.sh
+
+test_expect_success \
+    'Create an stgit branch from scratch' \
+    'stg init &&
+     stg branch -c foo &&
+     stg new p1 -m "p1"
+'
+
+test_expect_failure \
+    'Rename the current stgit branch' \
+    'stg branch -r foo bar
+'
+
+test_expect_success \
+    'Rename an stgit branch' \
+    'stg branch -c buz &&
+     stg branch -r foo bar &&
+     test -z `find .git -name foo | tee /dev/stderr`
+'
+
+test_done
Previous: Yann DirsonNext: Yann Dirson
Message 6 of 10 in “Add a testsuite to stgit (take 3), and more”
  1. 0/9 Add a testsuite to stgit (take 3), and moreYann Dirson, Apr 16, 2006
  2. 1/9 Add a testsuite framework copied from git-coreYann Dirson, Apr 16, 2006
  3. 2/9 Add list of bugs to TODOYann Dirson, Apr 16, 2006
  4. 3/9 Add a couple of safety checks to series creationYann Dirson, Apr 16, 2006
  5. 4/9 Make branch creation atomicYann Dirson, Apr 16, 2006
  6. 5/9 Correctly handle refs/patches on series renameYann Dirson, Apr 16, 2006
  7. 6/9 Fix a seriously bad interaction between .git caching and repo cloningYann Dirson, Apr 16, 2006
  8. 7/9 Test that pulls a patch creating a file that got modified afterwardsYann Dirson, Apr 16, 2006
  9. 8/9 Exercise "stg pull" on patches just appending lines.Yann Dirson, Apr 16, 2006
  10. 9/9 Look for templates in ~/.stgit/templates as wellYann Dirson, Apr 16, 2006

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.