From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3683 invoked from network); 12 Jul 2020 14:15:56 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 12 Jul 2020 14:15:56 -0000 Received: (qmail 1075 invoked by alias); 12 Jul 2020 14:15:44 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46237 Received: (qmail 18163 invoked by uid 1010); 12 Jul 2020 14:15:44 -0000 X-Qmail-Scanner-Diagnostics: from smtprelay02.ispgateway.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25863. spamassassin: 3.4.4. Clear:RC:0(80.67.18.14):SA:0(-2.6/5.0):. Processed in 4.331101 secs); 12 Jul 2020 14:15:44 -0000 X-Envelope-From: ft@jim.voodoo.lan X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at jim.voodoo.lan does not designate permitted sender hosts) From: Frank Terbeck 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 Message-Id: <20200712141239.14585-1-ft@bewatermyfriend.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Df-Sender: NDMwNDQ0 X-Qmail-Scanner-2.11: added fake Content-Type header Content-Type: text/plain 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