Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] git sync: replace 'git rev-parse' with safer '.git' check
Date: Sun, 18 Jan 2015 10:34:32
Message-Id: 1421577264-4779-1-git-send-email-mgorny@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] git sync: silence 'git rev-parse' errors by Zac Medico
1 The 'git rev-parse' could succeed if one of the parent directories
2 contained a git repository, and it also had unwanted error output.
3 Instead, just check whether the '.git' directory exists.
4 ---
5 pym/portage/sync/modules/git/git.py | 14 +-------------
6 1 file changed, 1 insertion(+), 13 deletions(-)
7
8 diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
9 index d4f2cc1..c5c569e 100644
10 --- a/pym/portage/sync/modules/git/git.py
11 +++ b/pym/portage/sync/modules/git/git.py
12 @@ -29,19 +29,7 @@ class GitSync(SyncBase):
13
14 def exists(self, **kwargs):
15 '''Tests whether the repo actually exists'''
16 - if kwargs:
17 - self._kwargs(kwargs)
18 - elif not self.repo:
19 - return False
20 -
21 - if not os.path.exists(self.repo.location):
22 - return False
23 - exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\
24 - (portage._shell_quote(self.repo.location),),
25 - **portage._native_kwargs(self.spawn_kwargs))
26 - if exitcode == 128:
27 - return False
28 - return True
29 + return os.path.exists(os.path.join(self.repo.location, '.git'))
30
31
32 def new(self, **kwargs):
33 --
34 2.2.1

Replies