about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2014-06-02 14:33:39 +0100
committerPeter Stephenson <pws@zsh.org>2014-06-02 14:33:39 +0100
commit09f29ef00cfc0bf69df322f77def5ddd87016eb3 (patch)
treedc97c14047134e2bf7cd77abfcf3d349809b0fa3
parent06a4913245b3f862e7343b37ee1fc268b4f8d6f5 (diff)
parentb85b09b78b52b07cf0b83ae7892676327828a37f (diff)
downloadzsh-09f29ef00cfc0bf69df322f77def5ddd87016eb3.tar.gz
zsh-09f29ef00cfc0bf69df322f77def5ddd87016eb3.tar.xz
zsh-09f29ef00cfc0bf69df322f77def5ddd87016eb3.zip
Fix merge conflict
-rw-r--r--ChangeLog5
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git14
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index eee973699..416953db4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@
 	glob scanner needed some coaxing with counting matches with (Y)
 	glob qualifier.
 
+2014-06-02  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 32662: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
+	vcs_info git: Fix stagedstr for empty repos
+
 2014-06-01  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 32653: Completion/Unix/Command/_php: complete files with the
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index a48dc390d..76ab92f33 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -128,16 +128,22 @@ elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-staged-change
     querystaged=1
 fi
 if (( querystaged || queryunstaged )) && \
-   [[ "$(${vcs_comm[cmd]} rev-parse --is-inside-git-dir 2> /dev/null)" != 'true' ]] && \
-   ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
+   [[ "$(${vcs_comm[cmd]} rev-parse --is-inside-work-tree 2> /dev/null)" == 'true' ]] ; then
     # Default: off - these are potentially expensive on big repositories
     if (( queryunstaged )) ; then
         ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
             gitunstaged=1
     fi
     if (( querystaged )) ; then
-        ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
-        (( $? && $? != 128 )) && gitstaged=1
+        if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
+            ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
+            (( $? && $? != 128 )) && gitstaged=1
+        else
+            # empty repository (no commits yet)
+            # 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the git empty tree.
+            ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules 4b825dc642cb6eb9a060e54bf8d69288fbee4904 2>/dev/null
+            (( $? && $? != 128 )) && gitstaged=1
+        fi
     fi
 fi