git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, "Aneesh Kumar" <aneesh.kumar@gmail.com>,
	"Karl Hasselström" <kha@treskal.com>
Subject: [StGit PATCH 3/4] Properly remove all config for a deleted branch
Date: Sat, 22 Sep 2007 10:46:31 +0200	[thread overview]
Message-ID: <20070922084630.29884.73015.stgit@yoghurt> (raw)
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,

  parent reply	other threads:[~2007-09-22  8:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21  4:40 stg branch --delete doesn't work Aneesh Kumar
2007-09-21  9:48 ` Karl Hasselström
2007-09-22  8:46   ` [StGit PATCH 0/4] Fix "stg branch --delete" Karl Hasselström
2007-09-22  8:46     ` [StGit PATCH 1/4] Don't special-case the "master" branch during branch delete Karl Hasselström
2007-09-22  8:46     ` [StGit PATCH 2/4] Don't try to delete the branch twice Karl Hasselström
2007-09-22  8:46     ` Karl Hasselström [this message]
2007-09-22  8:46     ` [StGit PATCH 4/4] Add simple test for "stg branch --delete" Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070922084630.29884.73015.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=aneesh.kumar@gmail.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).