+(defun debbugs-gnu-fix-patch (dir)
+ (setq dir (directory-file-name (expand-file-name dir)))
+ (goto-char (point-min))
+ (re-search-forward diff-file-header-re nil t)
+ (goto-char (match-beginning 0))
+ (let ((file-names (diff-hunk-file-names)))
+ (when (and file-names
+ (not (string-match "/" (car file-names))))
+ ;; We have a simple patch that refers to a file somewhere in the
+ ;; tree. Find it.
+ (when-let ((files (directory-files-recursively
+ dir (concat "^" (regexp-quote (car file-names))
+ "$"))))
+ (when (re-search-forward (concat "^[+]+ "
+ (regexp-quote (car file-names))
+ "[ \t]")
+ nil t)
+ (replace-match (concat "+++ a"
+ (substring (car files) (length dir))
+ "\t")
+ nil t))))))
+