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

[StGit PATCH 3/4] Properly remove all config for a deleted branch

From
Karl Hasselström <kha@treskal.com>
Date
Sep 22, 2007, 08:46 UTC
Message-ID
<20070922084630.29884.73015.stgit@yoghurt>
In-Reply-To
<20070922084334.29884.60506.stgit@yoghurt>

This uses "git-config --remove-section", which was first released in git 1.5.1-rc1. I'm not sure if this is later than what we used to depend on; we already use "git-config --rename-section", but that's been in since git 1.5.0-rc0.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/config.py |    7 +++++++
 stgit/stack.py  |    9 ++-------
 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/stgit/config.py b/stgit/config.py
index 799e1d7..51818bd 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -76,6 +76,13 @@ class GitConfig:
             ).returns([0, 1]).run()
         self.__cache.clear()
 
+    def remove_section(self, name):
+        """Remove a section in the config file. Silently do nothing if
+        the section doesn't exist."""
+        Run('git-repo-config', '--remove-section', name
+            ).returns([0, 1]).discard_stderr().discard_output()
+        self.__cache.clear()
+
     def set(self, name, value):
         Run('git-repo-config', name, value).run()
         self.__cache[name] = value
diff --git a/stgit/stack.py b/stgit/stack.py
index d6f6a6e..adfff25 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -744,13 +744,8 @@ class Series(PatchSet):
             except GitException:
                 out.warn('Could not delete branch "%s"' % self.get_name())
 
-        # Cleanup parent informations
-        # FIXME: should one day make use of git-config --section-remove,
-        # scheduled for 1.5.1
-        config.unset('branch.%s.remote' % self.get_name())
-        config.unset('branch.%s.merge' % self.get_name())
-        config.unset('branch.%s.stgit.parentbranch' % self.get_name())
-        config.unset(self.format_version_key())
+        config.remove_section('branch.%s' % self.get_name())
+        config.remove_section('branch.%s.stgit' % self.get_name())
 
     def refresh_patch(self, files = None, message = None, edit = False,
                       show_patch = False,
Previous: Karl HasselströmNext: Karl Hasselström
Message 6 of 7 in “stg branch --delete doesn't work”
  1. Aneesh KumarSep 21, 2007
  2. Karl HasselströmSep 21, 2007
  3. 0/4 Fix "stg branch --delete"Karl Hasselström, Sep 22, 2007
  4. 1/4 Don't special-case the "master" branch during branch deleteKarl Hasselström, Sep 22, 2007
  5. 2/4 Don't try to delete the branch twiceKarl Hasselström, Sep 22, 2007
  6. 3/4 Properly remove all config for a deleted branchKarl Hasselström, Sep 22, 2007
  7. 4/4 Add simple test for "stg branch --delete"Karl Hasselström, Sep 22, 2007

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.