From: Zac Medico <zmedico@gentoo.org>
To: "Michał Górny" <mgorny@gentoo.org>, "Zac Medico" <zmedico@gentoo.org>
Cc: gentoo-portage-dev@lists.gentoo.org
Subject: Re: [gentoo-portage-dev] [PATCH] git sync: silence 'git rev-parse' errors
Date: Sat, 17 Jan 2015 16:52:59 -0800 [thread overview]
Message-ID: <54BB03EB.6020906@gentoo.org> (raw)
In-Reply-To: <20150118013114.3d4b57b2@pomiot.lan>
On 01/17/2015 04:31 PM, Michał Górny wrote:
> Dnia 2015-01-17, o godz. 14:07:46
> Zac Medico <zmedico@gentoo.org> 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
next prev parent reply other threads:[~2015-01-18 0:53 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 [this message]
2015-01-18 10:34 ` [gentoo-portage-dev] [PATCH v2] git sync: replace 'git rev-parse' with safer '.git' check Michał Górny
2015-01-18 16:48 ` 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=54BB03EB.6020906@gentoo.org \
--to=zmedico@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
--cc=mgorny@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