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

[StGIT PATCH] Store branch description in the config file

From
Karl Hasselström <kha@treskal.com>
Date
May 14, 2007, 19:28 UTC
Message-ID
<20070514192528.26543.75736.stgit@yoghurt>
In-Reply-To
<7vy7jtyh8q.fsf@assigned-by-dhcp.cox.net>

Instead of storing the branch description in an StGIT-specific file, store it in the git config file, where tools other than StGIT can read and write it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
On 2007-05-12 12:27:49 -0700, Junio C Hamano wrote:
> Will it be something like
>
>       [branch "master"]
>               description = "My primary development line"

This was easier to do than I'd thought. I don't get quotes around the description, though; do I have to insert them manually? And what purpose do they serve?

 stgit/stack.py |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
index c105b21..7048af7 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -451,7 +451,6 @@ class Series(StgitObject):
                                        self.__name)
 
         self.__hidden_file = os.path.join(self._dir(), 'hidden')
-        self.__descr_file = os.path.join(self._dir(), 'description')
 
         # where this series keeps its patches
         self.__patch_dir = os.path.join(self._dir(), 'patches')
@@ -550,11 +549,23 @@ class Series(StgitObject):
         if os.path.isfile(protect_file):
             os.remove(protect_file)
 
+    def __branch_descr(self):
+        return 'branch.%s.description' % self.get_branch()
+
     def get_description(self):
-        return self._get_field('description') or ''
+        # Fall back to the .git/patches/<branch>/description file if
+        # the config variable is unset.
+        return (config.get(self.__branch_descr())
+                or self._get_field('description') or '')
 
     def set_description(self, line):
-        self._set_field('description', line)
+        if line:
+            config.set(self.__branch_descr(), line)
+        else:
+            config.unset(self.__branch_descr())
+        # Delete the old .git/patches/<branch>/description file if it
+        # exists.
+        self._set_field('description', None)
 
     def get_parent_remote(self):
         value = config.get('branch.%s.remote' % self.__name)
@@ -787,8 +798,6 @@ class Series(StgitObject):
             # (move functionality to StgitObject ?)
             if os.path.exists(self.__hidden_file):
                 os.remove(self.__hidden_file)
-            if os.path.exists(self.__descr_file):
-                os.remove(self.__descr_file)
             if os.path.exists(self._dir()+'/orig-base'):
                 os.remove(self._dir()+'/orig-base')
 
Previous: Yann DirsonNext: J. Bruce Fields
Message 29 of 35 in “Merging commits together into a super-commit”
  1. Alex BenneeMay 10, 2007
  2. Raimund BauerMay 10, 2007
  3. Alex BenneeMay 10, 2007
  4. Johannes SchindelinMay 10, 2007
  5. Johannes SixtMay 10, 2007
  6. Linus TorvaldsMay 10, 2007
  7. Carl WorthMay 10, 2007
  8. J. Bruce FieldsMay 10, 2007
  9. Carl WorthMay 10, 2007
  10. Petr BaudisMay 10, 2007
  11. Carl WorthMay 10, 2007
  12. Using StGIT for tweaking already-committed stuffPetr Baudis, May 10, 2007
  13. Carl WorthMay 10, 2007
  14. Integrate StGIT into Git? (Was: Re: Using StGIT for tweaking already-committed stuff)Jan Hudec, May 11, 2007
  15. Karl HasselströmMay 10, 2007
  16. Yann DirsonMay 11, 2007
  17. Karl HasselströmMay 11, 2007
  18. Yann DirsonMay 12, 2007
  19. Karl HasselströmMay 12, 2007
  20. Robin RosenbergMay 10, 2007
  21. Yann DirsonMay 12, 2007
  22. Jakub NarebskiMay 12, 2007
  23. Karl HasselströmMay 12, 2007
  24. Yann DirsonMay 12, 2007
  25. Karl HasselströmMay 12, 2007
  26. Junio C HamanoMay 12, 2007
  27. Karl HasselströmMay 13, 2007
  28. Yann DirsonMay 13, 2007
  29. Store branch description in the config fileKarl Hasselström, May 14, 2007
  30. J. Bruce FieldsMay 10, 2007
  31. Petr BaudisMay 10, 2007
  32. J. Bruce FieldsMay 10, 2007
  33. Transactions for git (and stgit) ?Yann Dirson, May 12, 2007
  34. Karl HasselströmMay 12, 2007
  35. Yann DirsonMay 12, 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.