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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>

---

 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,

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux