git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH] If a patch is not changed when pushing, reuse the same commit object
Date: Mon, 14 Apr 2008 23:21:50 +0200	[thread overview]
Message-ID: <20080414212150.7334.92647.stgit@yoghurt> (raw)

It should be marginally faster since we don't have to create a new
commit object, but mostly it's a cleanliness issue: rewriting history
when we don't have to is bad.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/lib/transaction.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 2946a67..9a23c01 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -175,8 +175,8 @@ class StackTransaction(object):
         """Attempt to push the named patch. If this results in conflicts,
         halts the transaction. If index+worktree are given, spill any
         conflicts to them."""
-        cd = self.patches[pn].data
-        cd = cd.set_committer(None)
+        orig_cd = self.patches[pn].data
+        cd = orig_cd.set_committer(None)
         s = ['', ' (empty)'][cd.is_nochange()]
         oldparent = cd.parent
         cd = cd.set_parent(self.__head)
@@ -204,7 +204,11 @@ class StackTransaction(object):
             except git.MergeException, e:
                 self.__halt(str(e))
         cd = cd.set_tree(tree)
-        self.patches[pn] = self.__stack.repository.commit(cd)
+        if any(getattr(cd, a) != getattr(orig_cd, a) for a in
+               ['parent', 'tree', 'author', 'message']):
+            self.patches[pn] = self.__stack.repository.commit(cd)
+        else:
+            s = ' (unmodified)'
         del self.unapplied[self.unapplied.index(pn)]
         self.applied.append(pn)
         out.info('Pushed %s%s' % (pn, s))

                 reply	other threads:[~2008-04-14 21:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20080414212150.7334.92647.stgit@yoghurt \
    --to=kha@treskal.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.
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 NNTP newsgroup(s).