From: Junio C Hamano <gitster@pobox.com>
To: John Keeping <john@keeping.me.uk>
Cc: git@vger.kernel.org, Kevin Bracey <kevin@bracey.fi>
Subject: Re: [PATCH v2] difftool: fix dir-diff when file does not exist in working tree
Date: Fri, 17 May 2013 11:46:15 -0700 [thread overview]
Message-ID: <7vhai1xx54.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130517182608.GB27005@serenity.lan> (John Keeping's message of "Fri, 17 May 2013 19:26:08 +0100")
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.
>
> 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
prev parent reply other threads:[~2013-05-17 18:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 17:29 [PATCH] difftool: fix dir-diff when file does not exist in working tree John Keeping
2013-05-17 18:10 ` Junio C Hamano
2013-05-17 18:26 ` [PATCH v2] " John Keeping
2013-05-17 18:46 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vhai1xx54.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
--cc=kevin@bracey.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox