GNU bug report logs - #62731
29.0.60; diff-apply-hunk doesn't work for creating new files

Previous Next

Package: emacs;

Reported by: sbaugh <at> catern.com

Date: Sun, 9 Apr 2023 01:15:02 UTC

Severity: normal

Found in version 29.0.60

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 62731 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: sbaugh <at> catern.com, 62731 <at> debbugs.gnu.org
Subject: Re: bug#62731: 29.0.60;
 diff-apply-hunk doesn't work for creating new files
Date: Wed, 02 Oct 2024 09:58:53 +0300
> Date: Wed, 2 Oct 2024 03:41:05 +0300
> From: Dmitry Gutov <dmitry <at> gutov.dev>
> 
> > 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.

I think Git uses other prefixes as well (something like i/ and r/,
perhaps?)  And relying on b/ being an existing directory can cause
false positives.  How about relying on the "--git" part in the
"diff --git" header instead, and in the Git case _always_ removing one
leading directory?  (And if this also happens with Hg, include that in
the test as well.)

Also, what about the opposite case, when NEW is /dev/null? does that
work correctly?

Thanks.




This bug report was last modified 217 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.