diff options
author | Glenn Morris <rgm@gnu.org> | 2013-02-11 00:28:08 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2013-02-11 00:28:08 -0800 |
commit | 5109429f09110cd817d87e1c361ac66aaee28431 (patch) | |
tree | b41427590654358dece88c8ed40a45f5e0a976e5 /lisp/vc/diff.el | |
parent | 97a1cd9d27e7d95263b475d03ce39c20a2ff4512 (diff) | |
download | emacs-5109429f09110cd817d87e1c361ac66aaee28431.tar.gz |
Check whether diff supports --label before using it
* lisp/vc/diff.el (diff-use-labels): New variable.
(diff-no-select): Use --label rather than -L, and first
check that it is supported.
Fixes: debbugs:11067
Diffstat (limited to 'lisp/vc/diff.el')
-rw-r--r-- | lisp/vc/diff.el | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el index 8b4ff792969..0fc0d2e3f73 100644 --- a/lisp/vc/diff.el +++ b/lisp/vc/diff.el @@ -114,6 +114,13 @@ specified in the variable `diff-switches' are passed to the diff command." tempfile)) (file-local-copy file-or-buf))) +(defvar diff-use-labels 'check + "Whether `diff-command' understands the \"--label\" option. +Possible values are: + t -- yes, it does + nil -- no, it does not + check -- try to probe whether it does") + (defun diff-no-select (old new &optional switches no-async buf) ;; Noninteractive helper for creating and reverting diff buffers (unless (bufferp new) (setq new (expand-file-name new))) @@ -121,6 +128,11 @@ specified in the variable `diff-switches' are passed to the diff command." (or switches (setq switches diff-switches)) ; If not specified, use default. (unless (listp switches) (setq switches (list switches))) (or buf (setq buf (get-buffer-create "*Diff*"))) + (when (eq 'check diff-use-labels) + (setq diff-use-labels + (with-temp-buffer + (when (ignore-errors (call-process diff-command nil t nil "--help")) + (if (search-backward "--label" nil t) t))))) (let* ((old-alt (diff-file-local-copy old)) (new-alt (diff-file-local-copy new)) (command @@ -130,11 +142,14 @@ specified in the variable `diff-switches' are passed to the diff command." ,@switches ,@(mapcar #'shell-quote-argument (nconc - (when (or old-alt new-alt) - (list "-L" (if (stringp old) - old (prin1-to-string old)) - "-L" (if (stringp new) - new (prin1-to-string new)))) + (and (or old-alt new-alt) + (eq diff-use-labels t) + (list "--label" + (if (stringp old) old + (prin1-to-string old)) + "--label" + (if (stringp new) new + (prin1-to-string new)))) (list (or old-alt old) (or new-alt new))))) " ")) |