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 546CA138A1A for ; Sun, 18 Jan 2015 00:53:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5A6B2E09AA; Sun, 18 Jan 2015 00:53:03 +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 CCAA2E097D for ; Sun, 18 Jan 2015 00:53:02 +0000 (UTC) Received: from [192.168.0.13] (ip174-67-205-96.oc.oc.cox.net [174.67.205.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 4D05D3406F4; Sun, 18 Jan 2015 00:53:01 +0000 (UTC) Message-ID: <54BB03EB.6020906@gentoo.org> Date: Sat, 17 Jan 2015 16:52:59 -0800 From: Zac Medico User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 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 MIME-Version: 1.0 To: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= , Zac Medico CC: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] git sync: silence 'git rev-parse' errors References: <1421497732-15029-1-git-send-email-mgorny@gentoo.org> <54BADD32.1010907@gentoo.org> <20150118013114.3d4b57b2@pomiot.lan> In-Reply-To: <20150118013114.3d4b57b2@pomiot.lan> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 139c7e13-25f7-42a8-a359-1af519970c45 X-Archives-Hash: f36b00cf6231ff7b3331edfd0d14c0d6 On 01/17/2015 04:31 PM, Michał Górny wrote: > Dnia 2015-01-17, o godz. 14:07:46 > Zac Medico napisał(a): > >> On 01/17/2015 04:28 AM, Michał Górny wrote: >>> Discard the git-rev-parse error output to avoid 'fatal: Not a git >>> repository [...]' errors when checking whether the repository exists. >>> --- >>> pym/portage/sync/modules/git/git.py | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py >>> index b97d501..02da037 100644 >>> --- a/pym/portage/sync/modules/git/git.py >>> +++ b/pym/portage/sync/modules/git/git.py >>> @@ -36,7 +36,7 @@ class GitSync(SyncBase): >>> >>> if not os.path.exists(self.repo.location): >>> return False >>> - exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\ >>> + exitcode = portage.process.spawn_bash("cd %s ; git rev-parse 2>/dev/null" %\ >>> (portage._shell_quote(self.repo.location),), >>> **portage._native_kwargs(self.spawn_kwargs)) >>> if exitcode == 128: >>> >> >> Why don't we just skip the git rev-parse call entirely, if not >> os.path.isdir(os.path.join(self.repo.location, ".git"))? > > I don't know ;). I guess the current magic is more 'correct', i.e. > distinguishes broken repo. Of course, it all will probably fall apart > if it's broken but...! Well, looking at the git-rev-parse man page, I'm wondering if it's an "undocumented feature" that it works without any arguments. Maybe we should use something like this instead: [ -z "$(git rev-parse --show-prefix 2>/dev/null || echo fail)" ] This will only return 0 if the current working directory is a valid git repo (versus a parent directory). -- Thanks, Zac