branch: externals/vc-jj
commit f8563a006db706dfd2613d3281ec3d3e177f3663
Author: Rudi Schlatte <[email protected]>
Commit: Rudi Schlatte <[email protected]>
Tell jj about ignored files
We need to modify .gitignore and also call `jj file untrack` or `jj
file track` as needed.
---
vc-jj.el | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/vc-jj.el b/vc-jj.el
index 517faeb20c..dd69e008e8 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -218,9 +218,25 @@ self.hidden(), \"\\n\"
(defalias 'vc-jj-responsible-p #'vc-jj-root)
(defun vc-jj-find-ignore-file (file)
- (expand-file-name ".gitignore"
- (vc-jj-root file)))
-
+ "Return the .gitignore file that controls FILE.
+Currently we return the .gitignore file at project root instead
+of checking for per-directory .gitignore files."
+ (expand-file-name ".gitignore" (vc-jj-root file)))
+
+(defun vc-jj-ignore (file &optional directory remove)
+ "Ignore FILE under DIRECTORY (default is `default-directory').
+FILE is a wildcard specification relative to DIRECTORY. If
+REMOVE is non-nil, remove FILE from ignored files instead.
+
+For jj, modify `.gitignore' and call `jj untrack' or `jj track'."
+ (let ((ignore (vc-jj-find-ignore-file file)))
+ (cond
+ (remove
+ (vc--remove-regexp (concat "^" (regexp-quote file) "\\(\n\\|$\\)")
ignore)
+ (call-process "jj" nil (list t nil) nil "file" "track" file))
+ (t
+ (vc--add-line file ignore)
+ (call-process "jj" nil (list t nil) nil "file" "untrack" file)))))
(defvar vc-jj-diff-switches '("--git"))