branch: externals/vc-got
commit f8a9db5613417ffb30e54495f6a83c2f8a64dfe2
Author: Omar Polo <[email protected]>
Commit: Omar Polo <[email protected]>
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