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):

# stg-freeze
set -ex
top=$(stg top)

# Freeze the current stack
branchname=$(basename $(readlink .git/HEAD))
while read patch
        cp .git/patches/$branchname/$patch/top 
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 pop
echo a2 >> a
stg refresh -mpatch-1-update
stg push
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 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):
+    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,

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

Reply via email to