Subject: Re: [PATCH 2/3] t7800: fix tests when difftool uses --no-symlinks

From: Johannes Sixt <[email-masked]>
Date: Fri, 22 Mar 2013 23:27:25 +0100

Am 22.03.2013 20:36, schrieb John Keeping:
> When 'git difftool --dir-diff' is using --no-symlinks (either explicitly
> or implicitly because it's running on Windows), any working tree files
> that have been copied to the temporary directory are copied back after
> the difftool completes.  This includes untracked files in the working
> tree.
> 
> During the tests, this means that the following sequence occurs:
> 
> 1) the shell opens "output" to redirect the difftool output
> 2) difftool copies the empty "output" to the temporary directory

But this should not happen, should it?

> 3) difftool runs "ls" which writes to "output"
> 4) difftool copies the empty "output" file back over the output of the
>    command
> 5) the output files doesn't contain the expected output, causing the
>    test to fail
> 
> Avoid this by writing the output into .git/ which will not be copied or
> overwritten.

Isn't this just painting over the bug that "output" is incorrectly copied?

> In the longer term, difftool probably needs to learn to warn the user
> instead of overwrite any changes that have been made to the working tree
> file.

Sure, but this is an independent issue.

> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index e694972..1eed439 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -319,29 +319,29 @@ test_expect_success PERL 'setup change in subdirectory' '
>  '
>  
>  test_expect_success PERL 'difftool -d' '
> -	git difftool -d --extcmd ls branch >output &&
> -	grep sub output &&
> -	grep file output
> +	git difftool -d --extcmd ls branch >.git/output &&
> +	grep sub .git/output &&
> +	grep file .git/output
>  '
> ...