From 9a6bcbe26b6032c39031773da020fd7bf4015953 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Sat, 22 Sep 2007 10:22:18 +0200 Subject: [PATCH] Properly remove all config for a deleted branch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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, -- 2.11.0