From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 732CD138A1A for ; Sun, 18 Jan 2015 10:34:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E268BE099D; Sun, 18 Jan 2015 10:34:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8064AE099B for ; Sun, 18 Jan 2015 10:34:31 +0000 (UTC) Received: from pomiot.lan (mgorny-1-pt.tunnel.tserv28.waw1.ipv6.he.net [IPv6:2001:470:70:353::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id CECFE340703; Sun, 18 Jan 2015 10:34:29 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= 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 Message-Id: <1421577264-4779-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.2.1 In-Reply-To: <54BADD32.1010907@gentoo.org> References: <54BADD32.1010907@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 3be3d08d-71db-468d-9c9f-82bd4ea1413e X-Archives-Hash: cf6f6127579633c2c66b99320f06e972 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