From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: sbaugh@catern.com, 62731@debbugs.gnu.org
Subject: bug#62731: 29.0.60; diff-apply-hunk doesn't work for creating new files
Date: Wed, 02 Oct 2024 09:58:53 +0300 [thread overview]
Message-ID: <86ldz70z4i.fsf@gnu.org> (raw)
In-Reply-To: <d15c73a0-7d4e-43ae-9323-d80d47e93b5c@gutov.dev> (message from Dmitry Gutov on Wed, 2 Oct 2024 03:41:05 +0300)
> Date: Wed, 2 Oct 2024 03:41:05 +0300
> From: Dmitry Gutov <dmitry@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.
next prev parent reply other threads:[~2024-10-02 6:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-09 1:14 bug#62731: 29.0.60; diff-apply-hunk doesn't work for creating new files sbaugh
2024-10-02 0:41 ` Dmitry Gutov
2024-10-02 6:58 ` Eli Zaretskii [this message]
2024-10-02 18:57 ` Dmitry Gutov
2024-10-02 19:41 ` Eli Zaretskii
2024-10-02 19:48 ` Dmitry Gutov
2024-10-03 5:47 ` Eli Zaretskii
2024-10-04 1:14 ` Dmitry Gutov
2024-10-07 23:28 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86ldz70z4i.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=62731@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
--cc=sbaugh@catern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).