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

Subject: [PATCH] fix stg edit command

From
Peter Oberndorfer <kumbayo84@arcor.de>
Date
Feb 12, 2008, 22:05 UTC
Message-ID
<200802122305.05696.kumbayo84@arcor.de>
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:
Show 5 quoted lines
> 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.

Show 14 quoted lines
> -    # 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
Previous: Karl HasselströmNext: Karl Hasselström
Message 6 of 21 in “StGit: kha/safe and kha/experimental updated”
  1. Karl HasselströmFeb 10, 2008
  2. 0/5 Convert "stg new" to the new infrastructureKarl Hasselström, Feb 10, 2008
  3. 1/5 Disable patchlog test for "stg new"Karl Hasselström, Feb 10, 2008
  4. 2/5 Convert "stg new" to the new infrastructureKarl Hasselström, Feb 10, 2008
  5. 3/5 Refactor --author/--committer optionsKarl Hasselström, Feb 10, 2008
  6. Subject: [PATCH] fix stg edit commandPeter Oberndorfer, Feb 12, 2008
  7. Karl HasselströmFeb 12, 2008
  8. Refactor --author/--committer optionsKarl Hasselström, Feb 12, 2008
  9. 4/5 Let "stg new" support more message optionsKarl Hasselström, Feb 10, 2008
  10. 5/5 Emacs mode: use "stg new --file"Karl Hasselström, Feb 10, 2008
  11. David KågedalFeb 11, 2008
  12. Karl HasselströmFeb 11, 2008
  13. 0/2 Convert "stg delete" to the new infrastructureKarl Hasselström, Feb 10, 2008
  14. 1/2 Convert "stg delete" to the new infrastructureKarl Hasselström, Feb 10, 2008
  15. 2/2 Emacs mode: delete patchesKarl Hasselström, Feb 10, 2008
  16. David KågedalFeb 11, 2008
  17. Karl HasselströmFeb 11, 2008
  18. David KågedalFeb 11, 2008
  19. 1/2 Emacs mode: change "stg repair" bindingKarl Hasselström, Feb 11, 2008
  20. 2/2 Emacs mode: delete patchesKarl Hasselström, Feb 11, 2008
  21. Catalin MarinasFeb 12, 2008

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.