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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Keeping <john@xxxxxxxxxxxxx> writes:

> 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.

Hmph.  Why do we populate the temporary directory with a copy of an
untracked path in the first place?  I thought the point of dir-diff
was to materialize only the relevant paths to two temporaries and
compare these temporaries with a tool that knows how to compare two
directories?

Even if you had path F in HEAD that you are no longer tracking in
the working tree, a normal

	$ git diff HEAD

would report the path F to have been deleted, so I would imagine
that the preimage side of the temporary directory should get a copy
of HEAD:F at path F, while the postimage side of the temporary
directory should not even have anything at path F, when dir-diff
runs, no?

Isn't that the real reason why the test fails?  The path 'output' is
not being tracked at any revision or in the index that is involved
in the test, is it?

> 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
> 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.

It is a good idea to move these test output and expect test vectore
files to a different place to make it easier to distinguish them
from test input (e.g. "sub", "file", etc.) in general, but the
description of the original problem sounds like it is just working
around a bug to me.  What am I missing?

> 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.
>
> Signed-off-by: John Keeping <john@xxxxxxxxxxxxx>
> ---
>  t/t7800-difftool.sh | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> 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
>  '
>  
>  test_expect_success PERL 'difftool --dir-diff' '
> -	git difftool --dir-diff --extcmd ls branch >output &&
> -	grep sub output &&
> -	grep file output
> +	git difftool --dir-diff --extcmd ls branch >.git/output &&
> +	grep sub .git/output &&
> +	grep file .git/output
>  '
>  
>  test_expect_success PERL 'difftool --dir-diff ignores --prompt' '
> -	git difftool --dir-diff --prompt --extcmd ls branch >output &&
> -	grep sub output &&
> -	grep file output
> +	git difftool --dir-diff --prompt --extcmd ls branch >.git/output &&
> +	grep sub .git/output &&
> +	grep file .git/output
>  '
>  
>  test_expect_success PERL 'difftool --dir-diff from subdirectory' '
>  	(
>  		cd sub &&
> -		git difftool --dir-diff --extcmd ls branch >output &&
> -		grep sub output &&
> -		grep file output
> +		git difftool --dir-diff --extcmd ls branch >../.git/output &&
> +		grep sub ../.git/output &&
> +		grep file ../.git/output
>  	)
>  '
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]