git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Walton <bwalton@artsci.utoronto.ca>
To: gitster@pobox.com, git@vger.kernel.org
Cc: Ben Walton <bwalton@artsci.utoronto.ca>
Subject: [PATCH 2/3] cvsimport: standarize open() calls to external git tools
Date: Tue, 19 Jan 2010 14:03:09 -0500	[thread overview]
Message-ID: <1263927790-1872-2-git-send-email-bwalton@artsci.utoronto.ca> (raw)
In-Reply-To: <1263927790-1872-1-git-send-email-bwalton@artsci.utoronto.ca>

This patch standardizes calls to open() where git modules are used as
part of a pipeline.  Instead of open(X, "git foo ... |)", use open(X,
"-|", qw(git foo ...)).  This standarization should see all calls made
without the use of an 'sh -c' process to split the arguments.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 git-cvsimport.perl |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index adffa0c..e838c2e 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -617,7 +617,7 @@ unless (-d $git_dir) {
 	$last_branch = $opt_o;
 	$orig_branch = "";
 } else {
-	open(F, "git symbolic-ref HEAD |") or
+	open(F, "-|", qw(git symbolic-ref HEAD)) or
 		die "Cannot run git symbolic-ref: $!\n";
 	chomp ($last_branch = <F>);
 	$last_branch = basename($last_branch);
@@ -631,8 +631,8 @@ unless (-d $git_dir) {
 
 	# Get the last import timestamps
 	my $fmt = '($ref, $author) = (%(refname), %(author));';
-	open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
-		die "Cannot run git for-each-ref: $!\n";
+	my @cmd = ('git', 'for-each-ref', '--perl', "--format=$fmt", $remote);
+	open(H, "-|", @cmd) or die "Cannot run git for-each-ref: $!\n";
 	while (defined(my $entry = <H>)) {
 		my ($ref, $author);
 		eval($entry) || die "cannot eval refs list: $@";
@@ -730,7 +730,7 @@ sub update_index (\@\@) {
 }
 
 sub write_tree () {
-	open(my $fh, '-|', "git write-tree")
+	open(my $fh, '-|', qw(git write-tree))
 		or die "unable to open git write-tree: $!";
 	chomp(my $tree = <$fh>);
 	is_sha1($tree)
-- 
1.6.5.3

  reply	other threads:[~2010-01-19 19:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17  3:55 [PATCH] cvsimport: update to use non-dash git commands Ben Walton
2010-01-17 17:35 ` [PATCH] cvsimport: modernize and standardize external tool calling Ben Walton
2010-01-17 19:15   ` Junio C Hamano
2010-01-19 19:03     ` [PATCH 1/3] cvsimport: modernize callouts to git subcommands Ben Walton
2010-01-19 19:03       ` Ben Walton [this message]
2010-01-19 19:03         ` [PATCH 3/3] cvsimport: standarize system() calls to external git tools Ben Walton

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=1263927790-1872-2-git-send-email-bwalton@artsci.utoronto.ca \
    --to=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).