Hi! On 09/04/2023 04:14, sbaugh@catern.com wrote: > 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. This is annoying indeed. The attached patch should handle this: * When OLD equals to /dev/null, allow reading non-existing file name. * When NEW starts with b/ or /a, slice that off if such dir does not exist. * Bonus: when the diff is applied in reverse, the checked file names are switched. That helps undo deletions as well. Or renames. It makes some assumptions, though, (such as that default-directory fits the file names in the diff, which is normal for vc diffs but maybe not others), so some testing would be welcome, especially from people who deal with diffs produced otherwise.