All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: David Aguilar <davvid@gmail.com>
Cc: Ismail Badawi <ismail@badawi.io>,
	John Keeping <john@keeping.me.uk>,
	Tim Henigan <tim.henigan@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] difftool: avoid symlinks when reusing worktree files
Date: Tue, 27 Oct 2015 15:41:33 -0700	[thread overview]
Message-ID: <xmqqwpu8lysi.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1445981088-6285-1-git-send-email-davvid@gmail.com> (David Aguilar's message of "Tue, 27 Oct 2015 14:24:48 -0700")

David Aguilar <davvid@gmail.com> writes:

> -	if (! -f "$workdir/$file") {
> -		return (0, $null_sha1);
> +	my $workfile = "$workdir/$file";
> +	if (-f $workfile && ! -l $workfile) {

I still don't know if return (0, $null) is the right thing to do,
but in any case, I find the original flow easier to read, i.e. "we
notice a few cases we cannot do the main 'hash-object' thing this
function is meant to do and return early".  I.e.

	if (-l "$workdir/$file" || ! -f _) {
        	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);

      parent reply	other threads:[~2015-10-27 22:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 21:24 [PATCH] difftool: avoid symlinks when reusing worktree files David Aguilar
2015-10-27 22:24 ` Junio C Hamano
2015-10-29  1:55   ` David Aguilar
2015-10-29 17:59     ` Junio C Hamano
2015-10-29 18:19       ` Junio C Hamano
2015-10-30  7:28         ` David Aguilar
2015-10-30 16:19           ` Junio C Hamano
2015-10-27 22:41 ` 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=xmqqwpu8lysi.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ismail@badawi.io \
    --cc=john@keeping.me.uk \
    --cc=tim.henigan@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.