about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-02-16 00:03:13 +0000
committerDaniel Shahaf <danielsh@apache.org>2020-02-17 10:02:27 +0000
commitbacad965238158b9ae6ff438ba923725ec128020 (patch)
tree343f0990c54ad2f5ae31dc2cf2c6ec8a471b94f0
parent459e2be810b7b01e79c832ee05d7ca7333c7c5fe (diff)
downloadzsh-bacad965238158b9ae6ff438ba923725ec128020.tar.gz
zsh-bacad965238158b9ae6ff438ba923725ec128020.tar.xz
zsh-bacad965238158b9ae6ff438ba923725ec128020.zip
github #48/0001: vcs_info git: avoid warnings in bare repositories
Git 2.25 introduced a change to how git rev-parse --show-toplevel
behaves.  Traditionally, it succeeded with no output if the user was
in a bare repository.  Now it dies, printing an error to standard error.
Consequently, when the user is in a bare repository with a newer Git,
vcs_info prints noisily to standard error.

While this is functionally harmless, it is annoying for the shell to
print messages from Git every time the prompt is printed, so let's
silence the error message.
-rw-r--r--ChangeLog6
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git2
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b95409a8..75751a547 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-17  brian m. carlson  <sandals@crustytoothpaste.net>
+
+	* github #48/0001:
+	Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git:
+	avoid warnings in bare repositories
+
 2020-02-14  dana  <dana@dana.is>
 
 	* unposted: Config/version.mk: Post-release version bump
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index ceb4f978a..0128c0981 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -138,7 +138,7 @@ VCS_INFO_git_handle_patches () {
 
 gitdir=${vcs_comm[gitdir]}
 VCS_INFO_git_getbranch ${gitdir}
-gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel )
+gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel 2> /dev/null )
 rrn=${gitbase:t}
 if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
     gitsha1=$(${vcs_comm[cmd]} rev-parse --quiet --verify HEAD)