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

[RFC] Stgit - patch history / add extra parents

From
Jan Veldeman <jan.veldeman@gmail.com>
Date
Aug 18, 2005, 19:57 UTC
Message-ID
<20050818195753.GA9066@fanta>
Hi,

I like stgit very much, but I feel there is still something missing: stgit is very handy when you use it for patches which should be pushed to mainline rather quickly. But for pacthes which won't be pushed immediately to mainline, it would be usefull to have a history of the patches itself.

The patch below, together with the following script could be used to make snapshots of the patch stack (I call it freeze, as I thought snapshot was already going to be used for something else):

#!/bin/bash # stg-freeze set -ex top=$(stg top)

# Freeze the current stack
branchname=$(basename $(readlink .git/HEAD))
while read patch
do
	cp .git/patches/$branchname/$patch/top .git/patches/$branchname/$patch/parent
done < .git/patches/$branchname/applied

# Refresh the patches stg pop -a stg push -t $top # end stg-freeze

Note: this is a proof of concept, when/if it would be incorporated, it
should be implemented in stgit itself, and a bit more efficient, especially
the refreshing of the patches ;-)

This is how it works: when not doing anything, stgit works as normal. Once stg-freeze is called, it creates .git/patches/$branchname/$patch/parent which contains the SHA1 id of the "frozen" patch. By refreshing the stack, all patches now include the corresponding frozen patch as a parent.

The following script is a test I use. Add stg-freeze to the path and source/run it in an empty directory, view with gitk afterwards:

### echo "Initial commit" | cg-init stg init

stg new a -mpatch-1 echo a > a stg add a stg refresh -mpatch-1 stg new b -mpatch-2 echo b > b stg add b stg refresh -mpatch-2 stg-freeze stg pop echo a2 >> a stg refresh -mpatch-1-update stg push stg-freeze echo b2 >> b stg refresh -mpatch-2-update

stg pop -a echo c > c cg-add c cg-commit -m"Mainline advance" stg push -a

stg-freeze

stg pop -a echo d > d cg-add d cg-commit -m"Mainline advance 2" stg push -a

stg pop -a echo e > e cg-add e cg-commit -m"Mainline advance 3" stg push -a

###
Comments/remarks are very welcome.
---
 stgit/stack.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -140,6 +140,13 @@ class Patch:
         elif os.path.isfile(fname):
             os.remove(fname)
 
+    def get_parents(self):
+        parents=[]
+        if (self.__get_field('parent') != None):
+                parents = parents + [self.__get_field('parent')]
+        parents = parents + [ self.get_bottom() ]
+        return parents
+
     def get_bottom(self):
         return self.__get_field('bottom')
 
@@ -362,7 +369,7 @@ class Series:
         if not committer_email:
             committer_email = patch.get_commemail()
 
-        commit_id = git.commit(message = descr, parents = [patch.get_bottom()],
+        commit_id = git.commit(message = descr, parents = patch.get_parents(),
                                allowempty = True,
                                author_name = author_name,
                                author_email = author_email,
Next: Catalin Marinas
Message 1 of 22 in “[RFC] Stgit - patch history / add extra parents”
  1. Jan VeldemanAug 18, 2005
  2. Catalin MarinasAug 19, 2005
  3. Jan VeldemanAug 19, 2005
  4. Catalin MarinasAug 19, 2005
  5. Jan VeldemanAug 19, 2005
  6. Catalin MarinasAug 20, 2005
  7. Jan VeldemanAug 21, 2005
  8. Daniel BarkalowAug 22, 2005
  9. Catalin MarinasAug 23, 2005
  10. Daniel BarkalowAug 23, 2005
  11. Jan VeldemanAug 23, 2005
  12. Daniel BarkalowAug 23, 2005
  13. Jan VeldemanAug 25, 2005
  14. Daniel BarkalowAug 25, 2005
  15. Catalin MarinasAug 31, 2005
  16. Catalin MarinasAug 31, 2005
  17. Catalin MarinasAug 30, 2005
  18. Jan VeldemanAug 31, 2005
  19. Daniel BarkalowAug 31, 2005
  20. Junio C HamanoAug 24, 2005
  21. Linus TorvaldsAug 24, 2005
  22. Junio C HamanoAug 23, 2005

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.