public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH v2] git sync: replace 'git rev-parse' with safer '.git' check
Date: Sun, 18 Jan 2015 11:34:24 +0100	[thread overview]
Message-ID: <1421577264-4779-1-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <54BADD32.1010907@gentoo.org>

The 'git rev-parse' could succeed if one of the parent directories
contained a git repository, and it also had unwanted error output.
Instead, just check whether the '.git' directory exists.
---
 pym/portage/sync/modules/git/git.py | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index d4f2cc1..c5c569e 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -29,19 +29,7 @@ class GitSync(SyncBase):
 
 	def exists(self, **kwargs):
 		'''Tests whether the repo actually exists'''
-		if kwargs:
-			self._kwargs(kwargs)
-		elif not self.repo:
-			return False
-
-		if not os.path.exists(self.repo.location):
-			return False
-		exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\
-			(portage._shell_quote(self.repo.location),),
-			**portage._native_kwargs(self.spawn_kwargs))
-		if exitcode == 128:
-			return False
-		return True
+		return os.path.exists(os.path.join(self.repo.location, '.git'))
 
 
 	def new(self, **kwargs):
-- 
2.2.1



  parent reply	other threads:[~2015-01-18 10:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-17 12:28 [gentoo-portage-dev] [PATCH] git sync: silence 'git rev-parse' errors Michał Górny
2015-01-17 22:07 ` Zac Medico
2015-01-18  0:31   ` Michał Górny
2015-01-18  0:52     ` Zac Medico
2015-01-18 10:34   ` Michał Górny [this message]
2015-01-18 16:48     ` [gentoo-portage-dev] [PATCH v2] git sync: replace 'git rev-parse' with safer '.git' check Brian Dolbec

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=1421577264-4779-1-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.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