Thread (7 messages) flat view 7 messages, 2 authors, 2016-06-15
DORMANTno replies

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

From: Karl Hasselström <hidden>
Date: 2016-06-15 22:43:36
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>

---

 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,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help