Subject: 29.0.60; diff-apply-hunk doesn't work for creating new files

From: [email-masked]
Date: Sun, 09 Apr 2023 01:14:25 +0000 (UTC)

1. emacs -Q
2. Put the following content in a diff-mode buffer:
diff --git a/foo b/foo
new file mode 100644
--- /dev/null
+++ b/foo
@@ -0,0 +1,1 @@
+content
3. C-c C-a

Expected behavior: A file called "foo" with content "content" is
created.

Observed behavior: diff-mode prompts for the location of "b/foo", and
doesn't allow specifying the location as a non-existent file, meaning
the file can't actaully be created.

In GNU Emacs 29.0.60 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
Repository revision: 4b6f2a7028b91128934a19f83572f24106782225
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: NixOS 21.11 (Porcupine)

Configured using:
 'configure
 --prefix=/nix/store/6d12l6xgg6bdqbv2l0k1nkpbixh93ib7-emacs-git-20220225.0
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Diff

Minor modes in effect:
  whitespace-mode: t
  envrc-global-mode: t
  envrc-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  windmove-mode: t
  tracking-mode: t
  savehist-mode: t
  save-place-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/sbaugh/.emacs.d/elpa/transient-0.3.7/transient hides /home/sbaugh/.local/src/emacs29/lisp/transient

Features:
(emacs-news-mode shadow emacsbug vc-annotate vc-dir vc-filewise
mode-local pcvs pcvs-defs pcvs-parse pcvs-info conf-mode magit-bundle
magit-gitignore magit-subtree ibuf-ext ibuf-macs mule-diag dos-w32
find-cmd apropos finder autoinsert pcmpl-unix pcmpl-gnu make-mode ido
benchmark term ehelp eshell esh-cmd esh-ext esh-opt esh-proc esh-io
esh-arg esh-module esh-groups esh-util ibuffer ibuffer-loaddefs
package-x eat term/xterm xterm eat-autoloads tramp-adb tramp-container
tramp-ftp loadhist timezone rect ediff-vers debbugs-browse time
flow-fill qp sort smiley gnus-cite mail-extr gnus-async gnus-bcklg
gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp gnus-ml
gnus-msg disp-table nndoc gnus-cache gnus-dup debbugs-gnu debbugs-compat
debbugs soap-client rng-xsd xsd-regexp debbugs-autoloads tar-mode
arc-mode archive-mode forge-list forge-commands forge-semi
forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab
forge-github ghub-graphql treepy gsexp ghub forge-notify forge-revnote
forge-pullreq forge-issue forge-topic yaml forge-post let-alist
markdown-mode forge-repo forge forge-core forge-db closql emacsql-sqlite
emacsql emacsql-compiler emoji-labels emoji multisession sqlite
org-attach tramp-cmds tramp-cache time-stamp tramp-sh shr-color textsec
uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check
skeleton mhtml-mode css-mode js c-ts-common sgml-mode facemenu nix-mode
nix-repl nix-shell nix-store nix-log nix-instantiate nix-shebang
nix-format nix ediff-ptch magit-patch tramp-archive tramp-gvfs tramp
tramp-loaddefs trampver tramp-integration tramp-compat ls-lisp
cursor-sensor magit-bookmark bookmark man find-dired grep org-capture
ob-ditaa ob-plantuml org-clock org-colview org-crypt org-ctags org-habit
org-mouse org-plot org-protocol novice pulse color git-rebase canlock
view image-file image-converter rmail goto-addr whitespace eglot
external-completion array jsonrpc ert flymake-proc flymake warnings
diary-lib diary-loaddefs cal-iso cus-dep loaddefs-gen cus-theme oc-basic
ol-eww eww url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus
nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr
pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start
gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo
parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader range
ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex iso8601
ol-bbdb ol-w3m ol-doi org-link-doi dired-aux sh-script smie executable
files-x tabify ggtags etags fileloop xref compile ewoc cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
debug backtrace cus-edit cus-start cus-load wid-edit lisp-mnt dabbrev pp
cl-print shortdoc completion help-fns radix-tree mm-archive
network-stream url-cache url-http url-auth url-gw nsm
display-line-numbers misc tmm mule-util misearch multi-isearch vc-hg
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference
magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help
ediff-init ediff-util vc-git vc-dispatcher face-remap ob-python python
pcase treesit agda2 envrc inheritenv page-ext dired-x magit-extras
project magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
which-func imenu magit-diff smerge-mode diff git-commit log-edit message
sendmail yank-media dired dired-loaddefs rfc822 mml mml-sec epa derived
epg rfc6068 epg-config gnus-util text-property-search mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process with-editor shell server
magit-mode transient edmacro kmacro magit-git magit-section magit-utils
crm dash cl-extra windmove lui-autopaste circe advice diff-mode
lui-irc-colors irc gnutls puny lcs lui-logging lui-format lui tracking
shorten help-mode flyspell ispell circe-compat ox-odt rng-loc rng-uri
rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table
ox-ascii ox-publish ox org-element org-persist xdg org-id org-refile
avl-tree generator org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-src ob-comint org-pcomplete pcomplete org-list
org-footnote org-faces org-entities time-date noutline outline icons
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol rx org-fold
org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar
cal-loaddefs org-version org-compat org-macs format-spec gdb-mi bindat
gud easy-mmode comint ansi-osc ansi-color ring ffap thingatpt
cyberpunk-theme savehist saveplace finder-inf envrc-autoloads
nix-mode-autoloads forge-autoloads htmlize-autoloads
slime-volleyball-autoloads graphviz-dot-mode-autoloads yaml-autoloads
auctex-autoloads tex-site notmuch-autoloads csv-mode-autoloads
ghub-autoloads treepy-autoloads circe-autoloads inheritenv-autoloads
mentor-autoloads url-scgi-autoloads xml-rpc-autoloads async-autoloads
ggtags-autoloads closql-autoloads emacsql-sqlite-autoloads
emacsql-autoloads magit-autoloads magit-section-autoloads
git-commit-autoloads with-editor-autoloads transient-autoloads
cyberpunk-theme-autoloads info dash-autoloads markdown-mode-autoloads
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine 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
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 5976716 623558)
 (symbols 48 79995 41)
 (strings 32 570566 317212)
 (string-bytes 1 39667351)
 (vectors 16 185988)
 (vector-slots 8 3509152 1022275)
 (floats 8 10130 8492)
 (intervals 56 578779 15775)
 (buffers 976 366))