Subject: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name

From: Tino Calancha <[email-masked]>
Date: Sun, 8 Nov 2015 00:12:03 +0900 (JST)

Congratulations!  You may have unearthed a bug in Ediff!

Please make a concise and accurate summary of what happened
and mail it to the address above.
-----------------------------------------------------------

ediff-patch-file fails if patch-buf is a buffer name

* lisp/vc/ediff.el (ediff-patch-file)

emacs -Q:
(in *scratch* buffer)

(with-temp-file "/tmp/buff"
   (insert "foo bar"))

(with-current-buffer (generate-new-buffer "buff2")
   (insert "foo baz"))

;; call ediff-buffers on "buff" and "buff2" and save the
;; differences in a buffer "patch"

(epatch nil (get-buffer "patch")) ; ok
(epatch nil "patch") ; BAD
epatch: Wrong type argument: bufferp, "patch"

Emacs  : GNU Emacs 25.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.28)
  of 2015-11-07
Package: Ediff 2.81.5 of July 4, 2013
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 3a2d1e4..e5c12cc 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -1367,7 +1367,8 @@ ediff-patch-file
     (require 'ediff-ptch)
     (setq patch-buf
 	  (ediff-get-patch-buffer
-	   (if arg (prefix-numeric-value arg)) patch-buf))
+	   (if arg (prefix-numeric-value arg)) (and (stringp patch-buf)
+                                                    (get-buffer patch-buf))))
     (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
 			   ((and (not ediff-patch-default-directory)
 				 (buffer-file-name patch-buf))