All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Oberndorfer <kumbayo84@arcor.de>
To: "Karl Hasselström" <kha@treskal.com>
Cc: "Catalin Marinas" <catalin.marinas@gmail.com>,
	git@vger.kernel.org, "David Kågedal" <davidk@lysator.liu.se>
Subject: Subject: [PATCH] fix stg edit command
Date: Tue, 12 Feb 2008 23:05:05 +0100	[thread overview]
Message-ID: <200802122305.05696.kumbayo84@arcor.de> (raw)
In-Reply-To: <20080210204359.17683.41935.stgit@yoghurt>

The comparison of two Commitdata objects returned False.
Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>
---

On Sonntag 10 Februar 2008, Karl Hasselström wrote:
> This refactoring is specific to the new infrastructure, so only new
> and edit use it currently, but other commands can start using it as
> they are converted.
> 
> Signed-off-by: Karl Hasselström <kha@treskal.com>

While testing my editor searching ordering patch i found that
this patch(Refactor --author/--committer options) seems to break
"stg edit" (without arguments) starting a interactive editor for me.
When i issue "stg edit" it silently does nothing.

It seems the following comparison does not return True

># Let user edit the patch manually.
>if cd == orig_cd or options.edit:

I can work around this by adding a comparison function to Commitdata
but maybe __eq__ or __ne__ should be used instead(prevent similar bugs caused
by == comparison)?
I would guess the initial cause for this is that the following line which unconditionally replaces cd.

> -    # Specify author and committer data.
> -    if options.author != None:
> -        options.authname, options.authemail = common.name_email(options.author)
> -    for p, f, val in [('author', 'name', options.authname),
> -                      ('author', 'email', options.authemail),
> -                      ('author', 'date', gitlib.Date.maybe(options.authdate)),
> -                      ('committer', 'name', options.commname),
> -                      ('committer', 'email', options.commemail)]:
> -        if val != None:
> -            cd = getattr(cd, 'set_' + p)(
> -                getattr(getattr(cd, p), 'set_' + f)(val))
> +    # Modify author and committer data.
> +    cd = (cd.set_author(options.author(cd.author))
> +            .set_committer(options.committer(cd.committer)))

So another way to fix this might be, to not overwrite cd unconditionally.

Greetings Peter

 stgit/commands/edit.py |    2 +-
 stgit/lib/git.py       |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index 037425b..9439fb6 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -146,7 +146,7 @@ def func(parser, options, args):
         return utils.STGIT_SUCCESS
 
     # Let user edit the patch manually.
-    if cd == orig_cd or options.edit:
+    if cd.is_same(orig_cd) or options.edit:
         fn = '.stgit-edit.' + ['txt', 'patch'][bool(options.diff)]
         cd, failed_diff = update_patch_description(
             stack.repository, cd, utils.edit_string(
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 6ee8a71..b62d14c 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -202,6 +202,14 @@ class Commitdata(Repr):
         return ('Commitdata<tree: %s, parents: %s, author: %s,'
                 ' committer: %s, message: "%s">'
                 ) % (tree, parents, self.author, self.committer, self.message)
+
+    def is_same(self, other):
+        return (self.__tree == other.__tree and
+                self.__parents == other.__parents and
+                self.__author == other.__author and
+                self.__committer == other.__committer and
+                self.__message == other.__message)
+
     @classmethod
     def parse(cls, repository, s):
         cd = cls()
-- 
1.5.4.rc3

  reply	other threads:[~2008-02-12 22:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10 20:36 StGit: kha/safe and kha/experimental updated Karl Hasselström
2008-02-10 20:40 ` [StGit PATCH 0/5] Convert "stg new" to the new infrastructure Karl Hasselström
2008-02-10 20:43   ` [StGit PATCH 1/5] Disable patchlog test for "stg new" Karl Hasselström
2008-02-10 20:43   ` [StGit PATCH 2/5] Convert "stg new" to the new infrastructure Karl Hasselström
2008-02-10 20:44   ` [StGit PATCH 3/5] Refactor --author/--committer options Karl Hasselström
2008-02-12 22:05     ` Peter Oberndorfer [this message]
2008-02-12 22:47       ` Subject: [PATCH] fix stg edit command Karl Hasselström
2008-02-12 23:08         ` [StGit PATCH] Refactor --author/--committer options Karl Hasselström
2008-02-10 20:44   ` [StGit PATCH 4/5] Let "stg new" support more message options Karl Hasselström
2008-02-10 20:46   ` [StGit PATCH 5/5] Emacs mode: use "stg new --file" Karl Hasselström
2008-02-11  9:25     ` David Kågedal
2008-02-11  9:47       ` Karl Hasselström
2008-02-10 20:47 ` [StGit PATCH 0/2] Convert "stg delete" to the new infrastructure Karl Hasselström
2008-02-10 20:48   ` [StGit PATCH 1/2] " Karl Hasselström
2008-02-10 20:54   ` [StGit PATCH 2/2] Emacs mode: delete patches Karl Hasselström
2008-02-11  9:42     ` David Kågedal
2008-02-11  9:51       ` Karl Hasselström
2008-02-11 10:12         ` David Kågedal
2008-02-11 22:25           ` [StGit PATCH 1/2] Emacs mode: change "stg repair" binding Karl Hasselström
2008-02-11 22:26           ` [StGit PATCH v2 2/2] Emacs mode: delete patches Karl Hasselström
2008-02-12 17:54 ` StGit: kha/safe and kha/experimental updated Catalin Marinas

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=200802122305.05696.kumbayo84@arcor.de \
    --to=kumbayo84@arcor.de \
    --cc=catalin.marinas@gmail.com \
    --cc=davidk@lysator.liu.se \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.