branch: externals/vc-jj
commit 846d16aa150d162703cb4421bdbc7a1c4328272e
Author: Javier Olaechea <pir...@gmail.com>
Commit: Rudi Schlatte <r...@constantly.at>

    Implement `vc-jj-root' using `vc-find-root' helper
    
    This avoids starting a process. The only edge case I could think of is
    the behaviour in the presence of backspaces. I verified that both `jj
    root` and `(vc-find-root file ".jj")` return the same result. jj
    creates a `.jj` directory on each workspace, vc-jj-root will return
    the top-level directory of the workspace as the root, both in the
    previous and the current version.
    
    Copyright-paperwork-exempt: yes
---
 vc-jj.el | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/vc-jj.el b/vc-jj.el
index fe5e529b39..3b5d49d64a 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -657,17 +657,7 @@ If REV is not specified, revert the file as with 
`vc-jj-revert'."
 (defun vc-jj-root (file)
   "Return the root of the repository containing FILE.
 Return NIL if FILE is not in a jj repository."
-  ;; `default-directory' must be an absolute directory name ending
-  ;; with a slash, so we go to some lengths to guarantee this, even
-  ;; for e.g. (vc-jj-root ".")
-  (let* ((absolute-file (expand-file-name file))
-         (default-directory
-          (file-name-as-directory (if (file-directory-p absolute-file)
-                                      absolute-file
-                                    (file-name-directory absolute-file)))))
-    (with-temp-buffer
-      (when (= 0 (call-process vc-jj-program nil (list t nil) nil "root"))
-        (file-name-as-directory (buffer-substring (point-min) (1- 
(point-max))))))))
+  (vc-find-root file ".jj"))
 
 (defalias 'vc-jj-responsible-p #'vc-jj-root)
 

Reply via email to