threads / patch / 2729

patchunneeded processing in forward_patches() ??

Subject: [PATCH] unneeded processing in forward_patches() ??

## tl;dr

2 messages between Dec 2, 2005 and Dec 2, 2005. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Chuck Lever· Dec 2, 2005, 00:11 UTC · lore

i was wondering why "stg push" takes so long to decide not to use fast-forward.

it turns out that when forward_patches() has not been able to fast- forward any patches, it still does a git.switch() and rewrites the unapplied file even though nothing has changed. on a big working directory, this 'no-op' can take a while.

following is a simple patch that addresses the problem. does this appear to be a reasonable optimization (in terms of correctness)?

        -- Chuck Lever
--
corporate:    <cel at netapp dot com>
personal:     <chucklever at bigfoot dot com>
Chuck Lever· Dec 2, 2005, 00:15 UTC · re: Chuck Lever · lore

[PATCH] Fast-forwarding does a git.switch() even when it forwarded no patches

The git.switch() in forward_patches() is not needed when no patches have been fast forwarded. This is a significant speed up.

Signed-off-by: Chuck Lever <cel@netapp.com>
---
 stgit/stack.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Show changes to stgit/stack.py +3 −0
diff --git a/stgit/stack.py b/stgit/stack.py
index 3fd6a46..3cc37c5 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -735,6 +735,9 @@ class Series:
             forwarded+=1
             unapplied.remove(name)
 
+        if forwarded == 0:
+            return 0
+
         git.switch(top)
 
         append_strings(self.__applied_file, names[0:forwarded])

← back to recent threads