Subject: bug#26028: 26.0.50; epatch for multifile patches

From: Arseny Sher <[email-masked]>
Date: Wed, 08 Mar 2017 20:29:52 +0300

Hello,

I am having trouble using epatch while applying multifile patches.
Consider the following simple example:

ars@ars-thinkpad ~/tmp $ mkdir -p old/src
ars@ars-thinkpad ~/tmp $ echo "void main() { }" > old/src/hello.c
ars@ars-thinkpad ~/tmp $ mkdir -p new/src
ars@ars-thinkpad ~/tmp $ echo "int main() { return 0; }" > new/src/hello.c
ars@ars-thinkpad ~/tmp $ diff -cr old/ new/ > tmp.patch
ars@ars-thinkpad ~/tmp $ cat tmp.patch
diff -cr old/src/hello.c new/src/hello.c
*** old/src/hello.c	2017-03-08 14:29:24.743846995 +0300
--- new/src/hello.c	2017-03-08 14:29:32.399846824 +0300
***************
*** 1 ****
! void main() { }
--- 1 ----
! int main() { return 0; }

Now I start emacs and do M-x epatch. First of all, it asks me for
patch buffer or file, I point to '~/tmp/tmp.patch'. Then it asks for
directory to patch, I say '~/tmp/old' and ediff complains

Ediff has inferred that
	/home/ars/tmp/old/hello.c
is assumed to be the target for this patch.  However, this file does not exist.

Please enter an alternative patch target ...

because it ignores the path ('src' directory in this case) to the file.
Ediff manual says: "Ediff can recognize multi-file patches only if they
are in the context format or GNU unified format. All other patches are
treated as 1-file patches. Ediff is [hopefully] using the same algorithm
as patch to determine which files need to be patched." If I understand
this correctly, my scenario should work, so it seems like a bug.

I tried it on GNU Emacs versions 25.1, 25.2 RC2 and daily build
26.0.50.2, sometimes on clean Emacs (emacs -q), and sometimes with
unified diff format (diff -u), the result is the same.

I use GNU/Linux, Linux Mint 17 (based on Ubuntu 14.04).

Below goes autogenerated info from report-emacs-bug.

In GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8)
 of 2016-10-26 built on lgw01-50
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:	Linux Mint 17 Qiana

Recent messages:
my-misc loaded
Loading /home/ars/.emacs.d/recentf...done
Cleaning up the recentf list...done (0 removed)
my-text-processing loaded
Loading font-lock...done
my-windows-frames-funcs loaded
coding styles loaded
my-gdb-stuff loaded
Loading quail/cyrillic...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=-snapshot --with-modules=yes --with-x=yes
 --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2
 -fstack-protector --param=ssp-buffer-size=4 -Wformat
 -Werror=format-security' CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_MONETARY: ru_RU.UTF-8
  value of $LC_NUMERIC: ru_RU.UTF-8
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  gud-tooltip-mode: t
  diff-hl-flydiff-mode: t
  global-diff-hl-mode: t
  diff-auto-refine-mode: t
  global-flycheck-mode: t
  projectile-mode: t
  ivy-mode: t
  show-paren-mode: t
  my-global-fci-mode: t
  global-linum-mode: t
  dired-omit-mode: t
  delete-selection-mode: t
  cua-mode: t
  recentf-mode: t
  savehist-mode: t
  global-undo-tree-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/.emacs.d/static_packages/all-the-icons.el/all-the-icons hides ~/.emacs.d/static_packages/all-the-icons
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/26.0.50/lisp/textmodes/ispell
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/26.0.50/lisp/textmodes/flyspell
/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/26.0.50/lisp/language/thai-word

Features:
(shadow sort mail-extr emacsbug message puny format-spec rfc822 mml
mml-sec epa derived epg gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils colir
color ggtags etags xref project windmove quail gud my-gdb-stuff
diff-hl-flydiff diff-hl edmacro kmacro face-remap vc-hg vc-git vc-dir
ewoc vc vc-dispatcher diff-mode flycheck json map find-func rx subr-x
coding-styles cc-styles cc-align cc-engine cc-vars cc-defs projectile
advice grep compile comint ansi-color ibuf-ext ibuffer ibuffer-loaddefs
ivy ivy-overlay ffap thingatpt xcscope ring paren disp-table
fill-column-indicator easy-mmode linum dired-x dired dired-loaddefs
my-windows-frames-funcs all-the-icons all-the-icons-faces
data-weathericons data-octicons data-fileicons data-faicons
data-alltheicons font-lock+ cl dash my-text-processing drag-stuff delsel
cua-base recentf tree-widget wid-edit savehist undo-tree diff autorevert
filenotify wombat-theme my-misc finder-inf tex-site info package
epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev
obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 288745 21478)
 (symbols 48 35267 1)
 (miscs 40 517 1228)
 (strings 32 74748 9913)
 (string-bytes 1 2122820)
 (vectors 16 35442)
 (vector-slots 8 683178 9673)
 (floats 8 665 276)
 (intervals 56 444 300)
 (buffers 976 13)
 (heap 1024 41802 1607))