[BUG] Changesets that create empty files produce bogus patches
Aaron Bentley
aaron.bentley at utoronto.ca
Thu Jul 28 17:51:07 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John A Meinel wrote:
> Well, if you do:
> touch a
> diff -u /dev/null a
>
> You get no output.
Yes, but I don't think anyone would claim no output is a patch. Patches
have a particular format, and the empty string doesn't match it. In
fact, diff produces a different status code when the files are the same,
as well as failing to emit a patch.
>>No patch. A patch to add an empty file might look like:
>>--- /dev/null
>>+++ mod/sub/sub/emptyfile.txt
>>@@ -0,0 +1,1 @@
>>+
>>\ No newline at end of file
>
>
> I don't know that the above is a genuine statement.
If you do echo -n a > nearlyemptyfile.txt and diff it, you'll get this:
- --- /dev/null
+++ mod/sub/sub/nearlyemptyfile.txt
@@ -0,0 +1,1 @@
+ a
\ No newline at end of file
So what I wrote was, I thought, a pretty obvious extrapolation.
> I would say that we
> could easily just realize that an "add" with no content means we should
> create an empty file.
Yes. If you just didn't invoke note_patch, it would make more sense.
> I think the above patch looks pretty ugly, and doesn't really make it
> clear that it is an empty file. (It could have whitespace)
I certainly have no need to champion bizarre patch kludges like that.
But at least it looks like a patch. As for whitespace, I'm not sure how
that's different from other patches. Whitespace differences are rarely
obvious. Colourizing patches helps.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFC6Qz70F+nu1YWqI0RAkBWAJ4iLF2RxqqhJkuyzKL9v63lA9835QCeObXA
rbe99npa3CycRywtlKtNPL4=
=g2tq
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list