git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] difftool: fix dir-diff when file does not exist in working tree

From
Junio C Hamano <gitster@pobox.com>
Date
May 17, 2013, 18:46 UTC
Message-ID
<7vhai1xx54.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130517182608.GB27005@serenity.lan>
John Keeping <john@keeping.me.uk> writes:
> It can't ever happen because we only call this if the mode is non-zero
> in which case the SHA-1 is only null if there are unstaged changes.
>
> However, I think this revised version is much clearer.
Yes, that makes the intention crystal clear.  I like it.
Show 40 quoted lines
>
>  git-difftool.perl   | 6 ++++++
>  t/t7800-difftool.sh | 7 +++++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/git-difftool.perl b/git-difftool.perl
> index 6780292..8a75205 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -92,6 +92,12 @@ sub use_wt_file
>  		return 0;
>  	}
>  
> +	if (! -e "$workdir/$file") {
> +		# If the file doesn't exist in the working tree, we cannot
> +		# use it.
> +		return (0, $null_sha1);
> +	}
> +
>  	my $wt_sha1 = $repo->command_oneline('hash-object', "$workdir/$file");
>  	my $use = ($sha1 eq $null_sha1) || ($sha1 eq $wt_sha1);
>  	return ($use, $wt_sha1);
> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index a6bd99e..d46f041 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -356,6 +356,13 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory' '
>  	)
>  '
>  
> +run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '
> +	test_when_finished git reset --hard &&
> +	rm file2 &&
> +	git difftool --dir-diff $symlinks --extcmd ls branch master >output &&
> +	grep file2 output
> +'
> +
>  write_script .git/CHECK_SYMLINKS <<\EOF
>  for f in file file2 sub/sub
>  do
Previous: John Keeping
Message 4 of 4 in “difftool: fix dir-diff when file does not exist in working tree”
  1. difftool: fix dir-diff when file does not exist in working treeJohn Keeping, May 17, 2013
  2. Junio C HamanoMay 17, 2013
  3. difftool: fix dir-diff when file does not exist in working treeJohn Keeping, May 17, 2013
  4. Junio C HamanoMay 17, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.