From: "Sam Liddicott" <sam@liddicott.com>
To: git@vger.kernel.org
Subject: let git-diff allow patch to delete empty files?
Date: Wed, 05 Nov 2008 12:22:06 -0000 [thread overview]
Message-ID: <49118FEE.30408@liddicott.com> (raw)
In some cases "patch" cannot apply diff's generated using git-diff, I've
had a "git diff" output look like this when an empty file was removed as
the only change:
diff --git a/source3/include/dcerpc.h b/source3/include/dcerpc.h
deleted file mode 100644
index e69de29..0000000
which patch rejected, saying:
patch: **** Only garbage was found in the patch input.
There is a ghastly diff notation recognized by patch, using the magic
date 1970-01-01 01:00:00.000000000 to signify deletion which git-diff
properly uses for non-empty files.
Empty files are a different matter because there is no unified diff that
can represent deletion of an empty file because patch doesn't like
unified diff's with no context.
However this equivalent pair works by making the file non-empty and then
deleting it.
diff -Nru 1/here 2/here
--- 1/here 2008-11-05 09:43:55.000000000 +0000
+++ 2/here 2008-11-05 09:43:58.000000000 +0000
@@ -0,0 +1 @@
+
diff -Nru 1/here 2/here
--- 1/here 2008-11-05 09:37:23.000000000 +0000
+++ 2/here 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
In considering this filthy hack we should recognize that currently :
* patch will choke on certain "git diff" output. If patch's exit code is
checked as part of a loop of patches, then the patch procedure will
fail. This happened to me
* if delete-empty-file is one action in a larger patch file it will do
nothing - which can be worse if the "existence" of a file affects the
build system.
This filthy hack fixes both problems.
Sam
next reply other threads:[~2008-11-05 12:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 12:22 Sam Liddicott [this message]
2008-11-05 14:49 ` let git-diff allow patch to delete empty files? Sam Liddicott
2008-11-05 21:09 ` Nanako Shiraishi
2008-11-06 8:30 ` Sam Liddicott
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=49118FEE.30408@liddicott.com \
--to=sam@liddicott.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