summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndřej Lysoněk <olysonek@redhat.com>2020-06-09 15:13:11 +0200
committerJean Delvare <jdelvare@suse.de>2020-06-09 15:13:11 +0200
commit664886c62ae6424f1229972f140403e239dd4267 (patch)
treef8b0fc61bc4e94818f05cdbfb39cd1c2ce61eeeb
parent5e5d19429ff354040de72c775c70fe0ab6f3061b (diff)
downloadquilt-664886c62ae6424f1229972f140403e239dd4267.tar.gz
quilt.el: Fix quilt-editable when QUILT_PATCHES_PREFIX is set
This patch fixes a bug in quilt-editable: if QUILT_PATCHES_PREFIX is set, quilt-editable will always return nil, even if the file being edited is part of the topmost patch. If QUILT_PATCHES_PREFIX is set, then 'quilt top' prints the patch name as a relative path to the patch. Since in quilt-editable we're running 'quilt top' from the top level directory, the printed patch path is in the form $QUILT_PATCHES/patch-name. Later on, we're looking for a cached version of the file that we're editing in .pc/. The patch directories are stored directly under .pc/, rather than .pc/$QUILT_PATCHES/, so we must remove the $QUILT_PATCHES/ prefix from the patch path. Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com> Signed-off-by: Jean Delvare <jdelvare@suse.de>
-rw-r--r--lib/quilt.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/quilt.el b/lib/quilt.el
index e961993..38456c1 100644
--- a/lib/quilt.el
+++ b/lib/quilt.el
@@ -69,6 +69,10 @@
(or (quilt--get-config-variable "QUILT_PC")
".pc"))
+(defun quilt-patches-prefix ()
+ "Return the value of the QUILT_PATCHES_PREFIX config variable. Return nil if it is unset."
+ (quilt--get-config-variable "QUILT_PATCHES_PREFIX"))
+
(defun quilt-find-dir (fn &optional prefn)
"Return the top level dir of quilt from FN."
(if (or (not fn) (equal fn "/") (equal fn prefn))
@@ -189,6 +193,11 @@
(setq n (1+ n))))
(completing-read p l nil t))
+(defun quilt--strip-patchname (pn)
+ "Return the name of patch PN sans the path to the patches directory."
+ (let ((patches-path (concat (quilt-patches-directory) "/")))
+ (substring pn (length patches-path))))
+
(defvar quilt-edit-top-only 't)
(defun quilt-editable (f)
"Return t if F is editable in terms of current patch. Return nil if otherwise."
@@ -199,7 +208,10 @@
(if (quilt-bottom-p)
(quilt-cmd "applied") ; to print error message
(setq dirs (if quilt-edit-top-only
- (list (substring (quilt-cmd-to-string "top") 0 -1))
+ (list (let ((patch (substring (quilt-cmd-to-string "top") 0 -1)))
+ (if (quilt-patches-prefix)
+ (quilt--strip-patchname patch)
+ patch)))
(cdr (cdr (directory-files (concat qd (quilt-pc-directory) "/"))))))
(while (and (not result) dirs)
(if (file-exists-p (concat qd (quilt-pc-directory) "/" (car dirs) "/" fn))