From: Phil Pokorny <ppokorny@penguincomputing.com>
To: git@vger.kernel.org
Subject: Problem with git format-patch and --src-prefix and --dst-prefix
Date: Thu, 12 Aug 2021 10:43:07 -0700 [thread overview]
Message-ID: <CAAek22FLBGWAM_MJmUag7YgfGCXLd58pruwLm2AsqMtohdmBLA@mail.gmail.com> (raw)
I'm trying to use git format-patch -> git am to port commits between
two repositories
In the source repository, the files are in the root directory of the
repository (./file) In the destination repository, the files are in a
sub-directory (./dir/file).
The --src-prefix and --dst-prefix seem to be the perfect tool for the
job of getting the patch stream output by format-patch to have the
right format to apply in the destination repository.
Like so:
git format-patch -N -p --src-prefix=a/dir/ --dst-prefix=/b/dir/ -o ../xfer.1
and then in the destination.
git am ../xfer.1
But in the resulting diff's in addition to the requested prefix
changes, there were also
'deleted file mode 100644' lines added.
It's subtle, but I now realize this was because of a typo (vs my
intent) in the above command. The --dst-prefix starts with a slash "/"
not "b/dir/" as I intended.
So I think I stumbled into a problem with the builtin_diff code here:
https://git.kernel.org/pub/scm/git/git.git/tree/diff.c?id=eab9a40b6dd5c1c571b1deb264133db47bb4794d#n1216
It uses the short-hand of testing just the first character of lbl[0]
and lbl[1] to decide if the source is /dev/null or the destination is
/dev/null to print "new file" or "deleted file" lines. But with
src-prefix and dst-prefix, those lines could be triggered incorrectly
with a prefix that begins with / which might have a legitimate reason
for others to do.
I'm new to git development, but I'm willing to try and work up a patch
if this is a valid issue and someone can help guide me through the
submission process.
Thanks,
Phil P.
reply other threads:[~2021-08-12 17:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAek22FLBGWAM_MJmUag7YgfGCXLd58pruwLm2AsqMtohdmBLA@mail.gmail.com \
--to=ppokorny@penguincomputing.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).