git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Problem with git format-patch and --src-prefix and --dst-prefix
@ 2021-08-12 17:43 Phil Pokorny
  0 siblings, 0 replies; only message in thread
From: Phil Pokorny @ 2021-08-12 17:43 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-12 17:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 17:43 Problem with git format-patch and --src-prefix and --dst-prefix Phil Pokorny

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.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).