git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git.__remotes_from_dir() should only return lists
@ 2007-09-05 16:57 Pavel Roskin
  2007-09-06 11:26 ` Karl Hasselström
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2007-09-05 16:57 UTC (permalink / raw)
  To: Catalin Marinas, kha, git

If there are no remotes, return empty list, not None.  The later doesn't
work with builtin set().

This fixes t1001-branch-rename.sh

Signed-off-by: Pavel Roskin <proski@gnu.org>
---

 stgit/git.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/stgit/git.py b/stgit/git.py
index 4b4c626..f847cce 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -953,7 +953,7 @@ def __remotes_from_dir(dir):
     if os.path.exists(d):
         return os.listdir(d)
     else:
-        return None
+        return []
 
 def remotes_list():
     """Return the list of remotes in the repository

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git.__remotes_from_dir() should only return lists
  2007-09-05 16:57 [PATCH] git.__remotes_from_dir() should only return lists Pavel Roskin
@ 2007-09-06 11:26 ` Karl Hasselström
  2007-09-06 12:38   ` Pavel Roskin
  0 siblings, 1 reply; 5+ messages in thread
From: Karl Hasselström @ 2007-09-06 11:26 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: Catalin Marinas, git

On 2007-09-05 12:57:22 -0400, Pavel Roskin wrote:

> If there are no remotes, return empty list, not None. The later
> doesn't work with builtin set().

Thanks. But I guess an even nicer fix would be to make this function
return a set in the first place.

> This fixes t1001-branch-rename.sh

Hmm. I don't believe I saw t1001 break without this patch (I run the
test suite before I push, but I might have made a mistake of course).
Does the user's environment leak into the test sandbox?

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git.__remotes_from_dir() should only return lists
  2007-09-06 11:26 ` Karl Hasselström
@ 2007-09-06 12:38   ` Pavel Roskin
  2007-09-06 14:26     ` Karl Hasselström
  2007-09-06 23:11     ` Karl Hasselström
  0 siblings, 2 replies; 5+ messages in thread
From: Pavel Roskin @ 2007-09-06 12:38 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: Catalin Marinas, git

On Thu, 2007-09-06 at 13:26 +0200, Karl Hasselström wrote:
> On 2007-09-05 12:57:22 -0400, Pavel Roskin wrote:
> 
> > If there are no remotes, return empty list, not None. The later
> > doesn't work with builtin set().
> 
> Thanks. But I guess an even nicer fix would be to make this function
> return a set in the first place.

Fine with me.  But it was returning a list or None, so the simplest fix
was to return a list in all cases.

> > This fixes t1001-branch-rename.sh
> 
> Hmm. I don't believe I saw t1001 break without this patch (I run the
> test suite before I push, but I might have made a mistake of course).
> Does the user's environment leak into the test sandbox?

I don't think it's the user environment, at least on my side.  I'm using
Fedora 7, which has python-2.5-12.fc7.  That's the error from the t1001
before my patch:

Traceback (most recent call last):
  File "/home/proski/src/stgit/t/../stg", line 43, in <module>
    main()
  File "/home/proski/src/stgit/stgit/main.py", line 284, in main
    command.func(parser, options, args)
  File "/home/proski/src/stgit/stgit/commands/branch.py", line 163, in func
    parentremote = git.identify_remote(parentbranch)
  File "/home/proski/src/stgit/stgit/git.py", line 994, in identify_remote
    for remote in remotes_list():
  File "/home/proski/src/stgit/stgit/git.py", line 963, in remotes_list
    | set(__remotes_from_dir('branches')))
TypeError: 'NoneType' object is not iterable

-- 
Regards,
Pavel Roskin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git.__remotes_from_dir() should only return lists
  2007-09-06 12:38   ` Pavel Roskin
@ 2007-09-06 14:26     ` Karl Hasselström
  2007-09-06 23:11     ` Karl Hasselström
  1 sibling, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2007-09-06 14:26 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: Catalin Marinas, git

On 2007-09-06 08:38:26 -0400, Pavel Roskin wrote:

> On Thu, 2007-09-06 at 13:26 +0200, Karl Hasselström wrote:
>
> > Thanks. But I guess an even nicer fix would be to make this
> > function return a set in the first place.
>
> Fine with me. But it was returning a list or None, so the simplest
> fix was to return a list in all cases.

Oh, your fix is excellent to fix the immediate problem. I was just
trying to say that making this function (an a heap of others) return
sets would be a useful refactoring.

> > Hmm. I don't believe I saw t1001 break without this patch (I run
> > the test suite before I push, but I might have made a mistake of
> > course). Does the user's environment leak into the test sandbox?
>
> I don't think it's the user environment, at least on my side. I'm
> using Fedora 7, which has python-2.5-12.fc7. That's the error from
> the t1001 before my patch:

OK. I'll try to reproduce it when I get home, but it certainly looks
like I only _thought_ I'd run the test suite.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git.__remotes_from_dir() should only return lists
  2007-09-06 12:38   ` Pavel Roskin
  2007-09-06 14:26     ` Karl Hasselström
@ 2007-09-06 23:11     ` Karl Hasselström
  1 sibling, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2007-09-06 23:11 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: Catalin Marinas, git

On 2007-09-06 08:38:26 -0400, Pavel Roskin wrote:

> On Thu, 2007-09-06 at 13:26 +0200, Karl Hasselström wrote:
>
> > Hmm. I don't believe I saw t1001 break without this patch (I run
> > the test suite before I push, but I might have made a mistake of
> > course). Does the user's environment leak into the test sandbox?
>
> I don't think it's the user environment, at least on my side. I'm
> using Fedora 7, which has python-2.5-12.fc7. That's the error from
> the t1001 before my patch:

Mmm, irritating. I really don't get the error, and debug printouts
confirm that it's because the directories .git/remotes and
.git/branches both exist.

Your patch is the right thing to do anyway, obviously.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-09-06 23:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-05 16:57 [PATCH] git.__remotes_from_dir() should only return lists Pavel Roskin
2007-09-06 11:26 ` Karl Hasselström
2007-09-06 12:38   ` Pavel Roskin
2007-09-06 14:26     ` Karl Hasselström
2007-09-06 23:11     ` Karl Hasselström

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).