git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Tim Henigan <tim.henigan@gmail.com>
Cc: gitster@pobox.com, davvid@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH 7/9] difftool: teach difftool to handle directory diffs
Date: Sat, 17 Mar 2012 07:32:12 -0700 (PDT)	[thread overview]
Message-ID: <m3fwd7l2mu.fsf@localhost.localdomain> (raw)
In-Reply-To: <1331949574-15192-1-git-send-email-tim.henigan@gmail.com>

Tim Henigan <tim.henigan@gmail.com> writes:

> +	foreach my $path (keys %submodule) {
> +		if (defined $submodule{$path}{left}) {
> +			open(SUBMOD, ">$ldir/$path") or die $!;
> +			print(SUBMOD "Subproject commit $submodule{$path}{left}");
> +			close(SUBMOD);
> +		}
> +		if (defined $submodule{$path}{right}) {
> +			open(SUBMOD, ">$rdir/$path") or die $!;
> +			print(SUBMOD "Subproject commit $submodule{$path}{right}");
> +			close(SUBMOD);

Could you please use modern Perl, and use lexical filehandles instead
of globs, and 3-arg version of 'open', i.e.

  +			open my $submod_fh, ">", "$ldir/$path" or die $!;
  +			print $submod_fh "Subproject commit $submodule{$path}{left}";
  +			close $submod_fh;


> +if (defined($dirdiff)) {
> +	my ($a, $b) = setup_dir_diff();
> +	if (defined($extcmd)) {
> +		system("$extcmd $a $b");
> +	} else {
> +		$ENV{GIT_DIFFTOOL_DIRDIFF} = 'true';
> +		system("git difftool--helper $a $b");
> +	}
> +	# TODO: if the diff including working copy files and those
> +	# files were modified during the diff, then the changes
> +	# should be copied back to the working tree
> +} else {
> +	if (defined($prompt)) {
> +		$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
> +	}
> +	elsif (defined($no_prompt)) {
> +		$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
> +	}
> +
> +	$ENV{GIT_PAGER} = '';
> +	$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
> +	git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
> +}

Why you use 'system' (and not in list form which does not require
escaping shell characters) instead of git_cmd_try for first 
"git difftool--helper" invocation?

Is $extcmd and resultof setup_dir_diff() to be treated as shell
snippet, and used in string form of 'system' without escaping shell
metacharacters (like ' ' in filename)?

-- 
Jakub Narebski

  parent reply	other threads:[~2012-03-17 14:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-17  1:59 [PATCH 7/9] difftool: teach difftool to handle directory diffs Tim Henigan
2012-03-17  3:08 ` David Aguilar
2012-03-17 14:18   ` Tim Henigan
2012-03-17 14:32 ` Jakub Narebski [this message]
2012-03-18  0:58   ` Tim Henigan
2012-03-20 17:43 ` Tim Henigan
2012-03-20 18:35   ` Junio C Hamano
2012-03-20 20:17     ` Tim Henigan

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=m3fwd7l2mu.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).