zsh-workers
 help / color / Atom feed
* [PATCH 1/3] vcs_info: Document internal function and variable
@ 2019-12-01  0:04 Daniel Shahaf
  2019-12-01  0:04 ` [PATCH 2/3] vcs_info cvs: Fix infinite loop when /CVS exists Daniel Shahaf
  2019-12-01  0:04 ` [PATCH 3/3] vcs_info svn: Fix infinite loop when /.svn exists Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2019-12-01  0:04 UTC (permalink / raw)
  To: zsh-workers

---
 Functions/VCS_Info/VCS_INFO_bydir_detect | 12 ++++++++++++
 Functions/VCS_Info/vcs_info              |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index b20c05c9c..29b261413 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -2,6 +2,18 @@
 ## Written by Frank Terbeck <ft@bewatermyfriend.org>
 ## Distributed under the same BSD-ish license as zsh itself.
 
+# Helper function for VCS_INFO_detect_*
+#
+# Usage:
+#     vcs_comm[detect_need_file]=FILENAMES VCS_INFO_bydir_detect DIRNAME
+# where DIRNAME is a directory name and FILENAMES is a space-separated list
+# of filenames.
+#
+# If any parent directory of the current working directory, other than the root
+# directory, contains a subdirectory named DIRNAME that contains a file whose name
+# is in FILENAMES, set vcs_comm[basedir] to the path of that parent directory and
+# return true.  Otherwise, return false.
+
 setopt localoptions NO_shwordsplit
 local dirname=$1
 local basedir="." file
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index d67ae6bf5..9f48bee75 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -59,6 +59,12 @@ vcs_info () {
     local -x LC_MESSAGES
     local -i maxexports
     local -a msgs
+
+    # vcs_comm is used internally for passing values among VCS_INFO_* functions.
+    # It is not part of the public API.
+    #
+    # hook_com, backend_misc, and user_data are public API; see zshcontrib(1)
+    # and Misc/vcs_info-examples.
     local -A vcs_comm hook_com backend_misc user_data
 
     LC_MESSAGES=C

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] vcs_info cvs: Fix infinite loop when /CVS exists.
  2019-12-01  0:04 [PATCH 1/3] vcs_info: Document internal function and variable Daniel Shahaf
@ 2019-12-01  0:04 ` Daniel Shahaf
  2019-12-01  0:04 ` [PATCH 3/3] vcs_info svn: Fix infinite loop when /.svn exists Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2019-12-01  0:04 UTC (permalink / raw)
  To: zsh-workers

---
I don't have cvs(1) installed, so I can't test this.  Could someone please
give this a quick test?

Thanks,

Daniel


 Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
index e9d172052..9b828bd11 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
@@ -5,11 +5,17 @@
 setopt localoptions NO_shwordsplit
 local cvsbranch cvsbase
 
+# Look for the most distant parent that still has a CVS subdirectory.
+# VCS_INFO_detect_cvs ensured that ./CVS/Repository exists.
 cvsbase="."
-while [[ -d "${cvsbase}/../CVS" ]]; do
-    cvsbase="${cvsbase}/.."
-done
 cvsbase=${cvsbase:P}
+while [[ -d "${cvsbase:h}/CVS" ]]; do
+    cvsbase="${cvsbase:h}"
+    if [[ $cvsbase == '/' ]]; then
+        break
+    fi
+done
+
 cvsbranch=$(< ./CVS/Repository)
 rrn=${cvsbase:t}
 cvsbranch=${cvsbranch##${rrn}/}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] vcs_info svn: Fix infinite loop when /.svn exists.
  2019-12-01  0:04 [PATCH 1/3] vcs_info: Document internal function and variable Daniel Shahaf
  2019-12-01  0:04 ` [PATCH 2/3] vcs_info cvs: Fix infinite loop when /CVS exists Daniel Shahaf
@ 2019-12-01  0:04 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2019-12-01  0:04 UTC (permalink / raw)
  To: zsh-workers

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index c1547950f..21590addd 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -46,17 +46,19 @@ if (( ${+svninfo[Working_Copy_Root_Path]} )); then
   ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
 else
   # svn 1.0-1.6
-  while [[ -d "${svnbase}/../.svn" ]]; do
+  svnbase=${svnbase:P}
+  while [[ -d "${svnbase:h}/.svn" ]]; do
       parentinfo=()
-      ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
+      ${vcs_comm[cmd]} info --non-interactive -- "${svnbase:h}" | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
       [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break
       svninfo=(${(kv)parentinfo})
-      svnbase="${svnbase}/.."
+      svnbase=${svnbase:h}
+      if [[ $svnbase == '/' ]]; then
+	  break
+      fi
   done
 fi
 
-svnbase=${svnbase:P}
-
 rrn=${svnbase:t}
 zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
 hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  0:04 [PATCH 1/3] vcs_info: Document internal function and variable Daniel Shahaf
2019-12-01  0:04 ` [PATCH 2/3] vcs_info cvs: Fix infinite loop when /CVS exists Daniel Shahaf
2019-12-01  0:04 ` [PATCH 3/3] vcs_info svn: Fix infinite loop when /.svn exists Daniel Shahaf

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git