From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs-info: Avoid error messages in bare git repositories
Date: Sun, 12 Jul 2020 16:12:39 +0200 [thread overview]
Message-ID: <20200712141239.14585-1-ft@bewatermyfriend.org> (raw)
A user reported error messages in bare repositories. I tracked this down to:
gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel 2> /dev/null )
fatal: this operation must be run in a work tree
This fixes the issue by avoiding the call in bare repositories.
---
I do wonder though, why this happens. Git didn't stop printing the error
to stderr. Shouldn't the redirection to /dev/null inside the command
substitution take care of this?
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 79429c8e0..932a13423 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -138,10 +138,10 @@ VCS_INFO_git_handle_patches () {
gitdir=${vcs_comm[gitdir]}
VCS_INFO_git_getbranch ${gitdir}
-gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel 2> /dev/null )
-if [[ -z ${gitbase} ]]; then
- # Bare repository
+if [[ "$(${vcs_comm[cmd]} rev-parse --is-bare-repository 2> /dev/null)" == 'true' ]]; then
gitbase=${gitdir:P}
+else
+ gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel 2> /dev/null )
fi
rrn=${gitbase:t}
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
--
2.27.0
next reply other threads:[~2020-07-12 14:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 14:12 Frank Terbeck [this message]
2020-07-12 20:53 ` Frank Terbeck
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=20200712141239.14585-1-ft@bewatermyfriend.org \
--to=ft@bewatermyfriend.org \
--cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).