emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vc-got f8a9db5 060/145: fix vc-got-repository-url for c


From: ELPA Syncer
Subject: [elpa] externals/vc-got f8a9db5 060/145: fix vc-got-repository-url for checkout of non-bare repos
Date: Thu, 9 Sep 2021 15:58:33 -0400 (EDT)

branch: externals/vc-got
commit f8a9db5613417ffb30e54495f6a83c2f8a64dfe2
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>

    fix vc-got-repository-url for checkout of non-bare repos
    
    before I assumed got could checkout only from bare repos, but it turns
    out this isn't the case.  This fixes it, making vc-got-repository-url
    more robust.  It first try to use .git/config if it exists, if it
    doesn't but there is a .git directory, don't do anything; finally try
    to parse config (assuming this is a bare repo).
---
 vc-got.el | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/vc-got.el b/vc-got.el
index 19f04bb..8440bf5 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -651,17 +651,24 @@ Value is returned as floating point fractional number of 
days."
   (let* ((default-directory (vc-got--repo-root))
          (remote-name (or remote-name "origin"))
          (heading (concat "[remote \"" remote-name "\"]"))
+         (conf (cond ((file-exists-p ".git/config")
+                      ".git/config")
+                     ((file-exists-p ".git")
+                      nil)
+                     ((file-exists-p "config")
+                      "config")))
          found)
     (with-temp-buffer
-      (insert-file-contents "config")
-      (goto-char (point-min))
-      (when (search-forward heading nil t)
-        (forward-line)
-        (while (and (not found)
-                    (looking-at ".*="))       ;too broad?
-          (when (looking-at ".*url = \\(.*\\)")
-            (setq found (match-string-no-properties 1))))
-        found))))
+      (when conf
+        (insert-file-contents conf)
+        (goto-char (point-min))
+        (when (search-forward heading nil t)
+          (forward-line)
+          (while (and (not found)
+                      (looking-at ".*="))       ;too broad?
+            (when (looking-at ".*url = \\(.*\\)")
+              (setq found (match-string-no-properties 1))))
+          found)))))
 
 (provide 'vc-got)
 ;;; vc-got.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]