Possible bug in bzr diff
Aaron Bentley
aaron.bentley at utoronto.ca
Tue Mar 21 20:46:54 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Goffredo Baroncelli wrote:
> Hi all,
>
> during the develop of the command "bzr patch", I found what I think a bug in
> the 'bzr diff' command.
>
> If a file is changed _AND_ is moved or an entry of its path is renamed,
> the diff is wrong:
> The output of the diff command should be
> --- a/dir/file
> instead
> --- a/new-dir/file
>
> The patch attached should solve the problem. A test case is added
I agree that the above is wrong, but I'm not certain your fix is right.
Diff cannot detect renames. So it emits a file move as a
delete/create pair.
e.g.
$ diff -rNu a b
diff -rNu a/bar b/bar
- --- a/bar 1969-12-31 19:00:00.000000000 -0500
+++ b/bar 2006-03-21 15:34:06.000000000 -0500
@@ -0,0 +1 @@
+Foo
diff -rNu a/foo b/foo
- --- a/foo 2006-03-21 15:33:45.000000000 -0500
+++ b/foo 1969-12-31 19:00:00.000000000 -0500
@@ -1 +0,0 @@
- -Foo
If you apply this patch to a, you get b.
But if you apply a rename patch, patch doesn't honour the rename.
Here is an example patch:
diff -rNu a/bar b/bar
- --- a/bar 2006-03-21 15:37:08.000000000 -0500
+++ b/baz 2006-03-21 15:38:30.000000000 -0500
@@ -1 +1 @@
- -Foo
+Foop
Applying it does not rename the file to baz, it only changes the content.
Since the primary target of bzr diff is the standard patch command, I
think we should emulate the standard diff's rename-insensitive behavour.
That means that every file that is renamed or modified should be
compared to its filename's content in the other tree.
Note that I say its *filename*'s content; it is possible that, in the
other tree, a file with a different file ID has that filename, so it
would appear to be modification of the other file ID's content.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEIGY+0F+nu1YWqI0RAuqjAJ96gCRMY1CPqMgf42JjphoGV0FpZwCfTLLC
SmAX0nx4+BtlG/WVTIDrXR0=
=69CI
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list