Possible bug in bzr diff

Martin Pool mbp at sourcefrog.net
Fri Apr 21 05:21:16 BST 2006

On 22/03/2006, at 6:48 AM, 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:
> example
> ghigo at venice:~/bazaar/test2$ bzr init
> ghigo at venice:~/bazaar/test2$ mkdir dir
> ghigo at venice:~/bazaar/test2$ echo 2 >>dir/file
> ghigo at venice:~/bazaar/test2$ bzr add *
> added dir
> added dir/file
> ghigo at venice:~/bazaar/test2$ bzr ci -m "commit"
> Committed revision 1.
> ghigo at venice:~/bazaar/test2$ echo 2 >>dir/file
> ghigo at venice:~/bazaar/test2$ bzr mv dir new-dir
> dir => new-dir
> ghigo at venice:~/bazaar/test2$ bzr diff
> === renamed directory 'a/dir' => 'b/new-dir'
> === modified file 'a/new-dir/file'
> --- a/new-dir/file          <-------------- the error is there
> +++ b/new-dir/file
> @@ -1,1 +1,2 @@
>  2
> +2
> 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 this is a better behaviour.  I disagree with Aaron that "the  
primary target for diff is patch"; for me it is far more common to  
read the output.  (I do it at least before every commit, and  
presumably am not alone.)  In any case the current behaviour does not  
support renames through patch properly anyhow.

This is +1 from me to merge for 0.8.

By way of feedback it may be better to have a collection of smaller  
tests, rather than one that checks so much output - then if one of  
them fails it may be easier to track down.  I'm not sure it would be  
simpler here -- this is just something to think about.

I have filed


asking for an option for diff that will produce output that works  
with plain patch.


More information about the bazaar mailing list