branch: externals/vc-jj
commit e8e1c3d71dab45bcd2bfb9564a330477a41958b0
Author: Kristoffer Balintona <krisbalint...@gmail.com>
Commit: Kristoffer Balintona <krisbalint...@gmail.com>

    fix: Make file paths relative to jj repo root
    
    Normalize all file paths passed to `vc-jj--filename-to-fileset` to be
    relative to the repository root.
    
    Actually fixes #62, which was incorrectly thought to be fixed by
    cca23877c1: users can now check in directories (all changed files
    inside directories, recursively).  It is unclear why the previously
    used "file:" is insufficient, but "root:" seems to remove the bug.
---
 vc-jj.el | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/vc-jj.el b/vc-jj.el
index 45a2806e74..7a31b9d68b 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -111,16 +111,11 @@ If nil, use the value of `vc-diff-switches'.  If t, use 
no switches."
                 (string :tag "Argument String")
                 (repeat :tag "Argument List" :value ("") string)))
 
-(defun vc-jj--filename-to-fileset (filename &optional root)
-  "Convert FILENAME to a JJ fileset expression.
-If ROOT is non-nil, the resulting fileset is relative to the repository
-root, otherwise it is relative to the current directory."
-  (if root
-      (concat "root:\""
-              (string-replace "\"" "\\\"" (file-relative-name filename root))
-              "\"")
-    (concat "file:\""
-            (string-replace "\"" "\\\"" (file-relative-name filename)) "\"")))
+(defun vc-jj--filename-to-fileset (filename)
+  "Convert FILENAME to a jj fileset expression.
+The fileset expression returned is relative to the jj repository root."
+  (when-let ((path (file-relative-name filename (vc-jj-root filename))))
+    (concat "root:\"" (string-replace "\"" "\\\"" path) "\"")))
 
 (defun vc-jj--process-lines (&rest args)
   "Run jj with ARGS, returning its output to stdout as a list of strings.

Reply via email to