{"thread":{"id":"22253","subject":"[PATCH] cvsimport: update to use non-dash git commands","startedAt":"2010-01-17T03:55:23Z","lastAt":"2010-01-19T19:03:10Z","messageCount":6,"participants":["Ben Walton","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131922","messageId":"1263700523-2111-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"22253","inReplyTo":null,"subject":"[PATCH] cvsimport: update to use non-dash git commands","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-01-17T03:55:23Z","receivedAt":"2010-01-17T03:55:23Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The cvsimport module was using the old git subcommand calling\nconvention (eg: git-init) in several places.  Clean this up to use\nonly modern calling conventions and be internally consistent in how\ncommands are passed to system().\n\nReported-by: Alexander Maier <amaier@opencsw.org>\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n git-cvsimport.perl |   32 ++++++++++++++++----------------\n 1 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex a7d215c..39e5842 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -609,16 +609,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};\n my %index; # holds filenames of one index per branch\n \n unless (-d $git_dir) {\n-\tsystem(\"git-init\");\n+\tsystem(qw(git init));\n \tdie \"Cannot init the GIT db at $git_tree: $?\\n\" if $?;\n-\tsystem(\"git-read-tree\");\n+\tsystem(qw(git read-tree));\n \tdie \"Cannot init an empty tree: $?\\n\" if $?;\n \n \t$last_branch = $opt_o;\n \t$orig_branch = \"\";\n } else {\n-\topen(F, \"git-symbolic-ref HEAD |\") or\n-\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n+\topen(F, \"git symbolic-ref HEAD |\") or\n+\t\tdie \"Cannot run git symbolic-ref: $!\\n\";\n \tchomp ($last_branch = <F>);\n \t$last_branch = basename($last_branch);\n \tclose(F);\n@@ -761,9 +761,9 @@ sub commit {\n \t\t$index{$branch} = tmpnam();\n \t\t$ENV{GIT_INDEX_FILE} = $index{$branch};\n \t\tif ($ancestor) {\n-\t\t    system(\"git-read-tree\", \"$remote/$ancestor\");\n+\t\t    system(qw(git read-tree), \"$remote/$ancestor\");\n \t\t} else {\n-\t\t    system(\"git-read-tree\", \"$remote/$branch\");\n+\t\t    system(qw(git read-tree), \"$remote/$branch\");\n \t\t}\n \t\tdie \"read-tree failed: $?\\n\" if $?;\n \t    }\n@@ -822,7 +822,7 @@ sub commit {\n \twaitpid($pid,0);\n \tdie \"Error running git-commit-tree: $?\\n\" if $?;\n \n-\tsystem('git-update-ref', \"$remote/$branch\", $cid) == 0\n+\tsystem(qw(git update-ref), \"$remote/$branch\", $cid) == 0\n \t\tor die \"Cannot write branch $branch for update: $!\\n\";\n \n \tif ($tag) {\n@@ -832,7 +832,7 @@ sub commit {\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n \t\t$xtag =~ s/\\[//g;\n \n-\t\tsystem('git-tag', '-f', $xtag, $cid) == 0\n+\t\tsystem(qw(git tag -f), $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n \n \t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n@@ -993,7 +993,7 @@ while (<CVS>) {\n \t\t}\n \t\tcommit();\n \t\tif (($commitcount & 1023) == 0) {\n-\t\t\tsystem(\"git repack -a -d\");\n+\t\t\tsystem(qw(git repack -a -d));\n \t\t}\n \t\t$state = 1;\n \t} elsif ($state == 11 and /^-+$/) {\n@@ -1017,7 +1017,7 @@ my $line = `git-count-objects`;\n if ($line =~ /^(\\d+) objects, (\\d+) kilobytes$/) {\n   my ($n_objects, $kb) = ($1, $2);\n   1024 < $kb\n-    and system(\"git repack -a -d\");\n+    and system(qw(git repack -a -d));\n }\n \n foreach my $git_index (values %index) {\n@@ -1042,24 +1042,24 @@ if ($orig_branch) {\n \tif ($tip_at_start ne $tip_at_end) {\n \t\tfor ($tip_at_start, $tip_at_end) { chomp; }\n \t\tprint \"Fetched into the current branch.\\n\" if $opt_v;\n-\t\tsystem(qw(git-read-tree -u -m),\n+\t\tsystem(qw(git read-tree -u -m),\n \t\t       $tip_at_start, $tip_at_end);\n \t\tdie \"Fast-forward update failed: $?\\n\" if $?;\n \t}\n \telse {\n-\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$opt_o\");\n+\t\tsystem(qw(git merge cvsimport HEAD), \"$remote/$opt_o\");\n \t\tdie \"Could not merge $opt_o into the current branch.\\n\" if $?;\n \t}\n } else {\n \t$orig_branch = \"master\";\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n-\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n+\tsystem(qw(git update-ref refs/heads/master), \"$remote/$opt_o\")\n \t\tunless defined get_headref('refs/heads/master');\n-\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n+\tsystem(qw(git symbolic-ref), \"$remote/HEAD\", \"$remote/$opt_o\")\n \t\tif ($opt_r && $opt_o ne 'HEAD');\n-\tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n+\tsystem(qw(git update-ref HEAD), \"$orig_branch\");\n \tunless ($opt_i) {\n-\t\tsystem('git checkout -f');\n+\t\tsystem(qw(git checkout -f));\n \t\tdie \"checkout failed: $?\\n\" if $?;\n \t}\n }\n-- \n1.6.6\n"},{"id":"131953","messageId":"1263749749-3939-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"22253","inReplyTo":"1263700523-2111-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH] cvsimport: modernize and standardize external tool calling","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-01-17T17:35:49Z","receivedAt":"2010-01-17T17:35:49Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The cvsimport module was mixing old (git-foo) and new (git foo)\nconventions when calling git tools.  This patch standardizes the\ncalling conventions used in system(), open(), exec() and backticks.\n\nReported-by: Alexander Maier <amaier@opencsw.org>\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\nThis takes into account the feedback from Junio.  It's a deeper change,\nbut should be better, overall.\n\n git-cvsimport.perl |   70 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 35 insertions(+), 35 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex a7d215c..24a31b3 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -609,16 +609,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};\n my %index; # holds filenames of one index per branch\n \n unless (-d $git_dir) {\n-\tsystem(\"git-init\");\n+\tsystem(qw(git init));\n \tdie \"Cannot init the GIT db at $git_tree: $?\\n\" if $?;\n-\tsystem(\"git-read-tree\");\n+\tsystem(qw(git read-tree));\n \tdie \"Cannot init an empty tree: $?\\n\" if $?;\n \n \t$last_branch = $opt_o;\n \t$orig_branch = \"\";\n } else {\n-\topen(F, \"git-symbolic-ref HEAD |\") or\n-\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n+\topen(F, '-|', 'git symbolic-ref HEAD') or\n+\t\tdie \"Cannot run git symbolic-ref: $!\\n\";\n \tchomp ($last_branch = <F>);\n \t$last_branch = basename($last_branch);\n \tclose(F);\n@@ -627,12 +627,12 @@ unless (-d $git_dir) {\n \t\t$last_branch = \"master\";\n \t}\n \t$orig_branch = $last_branch;\n-\t$tip_at_start = `git-rev-parse --verify HEAD`;\n+\t$tip_at_start = `git rev-parse --verify HEAD`;\n \n \t# Get the last import timestamps\n \tmy $fmt = '($ref, $author) = (%(refname), %(author));';\n-\topen(H, \"git-for-each-ref --perl --format='$fmt' $remote |\") or\n-\t\tdie \"Cannot run git-for-each-ref: $!\\n\";\n+\topen(H, '-|', \"git for-each-ref --perl --format='$fmt' $remote\") or\n+\t\tdie \"Cannot run git for-each-ref: $!\\n\";\n \twhile (defined(my $entry = <H>)) {\n \t\tmy ($ref, $author);\n \t\teval($entry) || die \"cannot eval refs list: $@\";\n@@ -687,7 +687,7 @@ unless ($opt_P) {\n \t    print $cvspsfh $_;\n \t}\n \tclose CVSPS;\n-\t$? == 0 or die \"git-cvsimport: fatal: cvsps reported error\\n\";\n+\t$? == 0 or die \"git cvsimport: fatal: cvsps reported error\\n\";\n \tclose $cvspsfh;\n } else {\n \t$cvspsfile = munge_user_filename($opt_P);\n@@ -716,27 +716,27 @@ my $state = 0;\n sub update_index (\\@\\@) {\n \tmy $old = shift;\n \tmy $new = shift;\n-\topen(my $fh, '|-', qw(git-update-index -z --index-info))\n-\t\tor die \"unable to open git-update-index: $!\";\n+\topen(my $fh, '|-', 'git update-index -z --index-info')\n+\t\tor die \"unable to open git update-index: $!\";\n \tprint $fh\n \t\t(map { \"0 0000000000000000000000000000000000000000\\t$_\\0\" }\n \t\t\t@$old),\n \t\t(map { '100' . sprintf('%o', $_->[0]) . \" $_->[1]\\t$_->[2]\\0\" }\n \t\t\t@$new)\n-\t\tor die \"unable to write to git-update-index: $!\";\n+\t\tor die \"unable to write to git update-index: $!\";\n \tclose $fh\n-\t\tor die \"unable to write to git-update-index: $!\";\n-\t$? and die \"git-update-index reported error: $?\";\n+\t\tor die \"unable to write to git update-index: $!\";\n+\t$? and die \"git update-index reported error: $?\";\n }\n \n sub write_tree () {\n-\topen(my $fh, '-|', qw(git-write-tree))\n-\t\tor die \"unable to open git-write-tree: $!\";\n+\topen(my $fh, '-|', 'git write-tree')\n+\t\tor die \"unable to open git write-tree: $!\";\n \tchomp(my $tree = <$fh>);\n \tis_sha1($tree)\n \t\tor die \"Cannot get tree id ($tree): $!\";\n \tclose($fh)\n-\t\tor die \"Error running git-write-tree: $?\\n\";\n+\t\tor die \"Error running git write-tree: $?\\n\";\n \tprint \"Tree ID $tree\\n\" if $opt_v;\n \treturn $tree;\n }\n@@ -751,7 +751,7 @@ sub commit {\n \tif ($branch eq $opt_o && !$index{branch} &&\n \t\t!get_headref(\"$remote/$branch\")) {\n \t    # looks like an initial commit\n-\t    # use the index primed by git-init\n+\t    # use the index primed by git init\n \t    $ENV{GIT_INDEX_FILE} = \"$git_dir/index\";\n \t    $index{$branch} = \"$git_dir/index\";\n \t} else {\n@@ -761,9 +761,9 @@ sub commit {\n \t\t$index{$branch} = tmpnam();\n \t\t$ENV{GIT_INDEX_FILE} = $index{$branch};\n \t\tif ($ancestor) {\n-\t\t    system(\"git-read-tree\", \"$remote/$ancestor\");\n+\t\t    system(qw(git read-tree), \"$remote/$ancestor\");\n \t\t} else {\n-\t\t    system(\"git-read-tree\", \"$remote/$branch\");\n+\t\t    system(qw(git read-tree), \"$remote/$branch\");\n \t\t}\n \t\tdie \"read-tree failed: $?\\n\" if $?;\n \t    }\n@@ -798,7 +798,7 @@ sub commit {\n \t$ENV{GIT_COMMITTER_EMAIL} = $author_email;\n \t$ENV{GIT_COMMITTER_DATE} = $commit_date;\n \tmy $pid = open2(my $commit_read, my $commit_write,\n-\t\t'git-commit-tree', $tree, @commit_args);\n+\t\t'git', 'commit-tree', $tree, @commit_args);\n \n \t# compatibility with git2cvs\n \tsubstr($logmsg,32767) = \"\" if length($logmsg) > 32767;\n@@ -811,7 +811,7 @@ sub commit {\n \t}\n \n \tprint($commit_write \"$logmsg\\n\") && close($commit_write)\n-\t\tor die \"Error writing to git-commit-tree: $!\\n\";\n+\t\tor die \"Error writing to git commit-tree: $!\\n\";\n \n \tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $opt_v;\n \tchomp(my $cid = <$commit_read>);\n@@ -820,9 +820,9 @@ sub commit {\n \tclose($commit_read);\n \n \twaitpid($pid,0);\n-\tdie \"Error running git-commit-tree: $?\\n\" if $?;\n+\tdie \"Error running git commit-tree: $?\\n\" if $?;\n \n-\tsystem('git-update-ref', \"$remote/$branch\", $cid) == 0\n+\tsystem(qw(git update-ref), \"$remote/$branch\", $cid) == 0\n \t\tor die \"Cannot write branch $branch for update: $!\\n\";\n \n \tif ($tag) {\n@@ -832,7 +832,7 @@ sub commit {\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n \t\t$xtag =~ s/\\[//g;\n \n-\t\tsystem('git-tag', '-f', $xtag, $cid) == 0\n+\t\tsystem(qw(git tag -f), $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n \n \t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n@@ -969,7 +969,7 @@ while (<CVS>) {\n \t\t\tmy $pid = open(my $F, '-|');\n \t\t\tdie $! unless defined $pid;\n \t\t\tif (!$pid) {\n-\t\t\t    exec(\"git-hash-object\", \"-w\", $tmpname)\n+\t\t\t    exec(\"git\", \"hash-object\", \"-w\", $tmpname)\n \t\t\t\tor die \"Cannot create object: $!\\n\";\n \t\t\t}\n \t\t\tmy $sha = <$F>;\n@@ -993,7 +993,7 @@ while (<CVS>) {\n \t\t}\n \t\tcommit();\n \t\tif (($commitcount & 1023) == 0) {\n-\t\t\tsystem(\"git repack -a -d\");\n+\t\t\tsystem(qw(git repack -a -d));\n \t\t}\n \t\t$state = 1;\n \t} elsif ($state == 11 and /^-+$/) {\n@@ -1013,11 +1013,11 @@ unless ($opt_P) {\n # The heuristic of repacking every 1024 commits can leave a\n # lot of unpacked data.  If there is more than 1MB worth of\n # not-packed objects, repack once more.\n-my $line = `git-count-objects`;\n+my $line = `git count-objects`;\n if ($line =~ /^(\\d+) objects, (\\d+) kilobytes$/) {\n   my ($n_objects, $kb) = ($1, $2);\n   1024 < $kb\n-    and system(\"git repack -a -d\");\n+    and system(qw(git repack -a -d));\n }\n \n foreach my $git_index (values %index) {\n@@ -1038,28 +1038,28 @@ if ($orig_branch) {\n \tif ($opt_i) {\n \t\texit 0;\n \t}\n-\tmy $tip_at_end = `git-rev-parse --verify HEAD`;\n+\tmy $tip_at_end = `git rev-parse --verify HEAD`;\n \tif ($tip_at_start ne $tip_at_end) {\n \t\tfor ($tip_at_start, $tip_at_end) { chomp; }\n \t\tprint \"Fetched into the current branch.\\n\" if $opt_v;\n-\t\tsystem(qw(git-read-tree -u -m),\n+\t\tsystem(qw(git read-tree -u -m),\n \t\t       $tip_at_start, $tip_at_end);\n \t\tdie \"Fast-forward update failed: $?\\n\" if $?;\n \t}\n \telse {\n-\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$opt_o\");\n+\t\tsystem(qw(git merge cvsimport HEAD), \"$remote/$opt_o\");\n \t\tdie \"Could not merge $opt_o into the current branch.\\n\" if $?;\n \t}\n } else {\n \t$orig_branch = \"master\";\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n-\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n+\tsystem(qw(git update-ref refs/heads/master), \"$remote/$opt_o\")\n \t\tunless defined get_headref('refs/heads/master');\n-\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n+\tsystem(qw(git symbolic-ref), \"$remote/HEAD\", \"$remote/$opt_o\")\n \t\tif ($opt_r && $opt_o ne 'HEAD');\n-\tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n+\tsystem(qw(git update-ref HEAD), \"$orig_branch\");\n \tunless ($opt_i) {\n-\t\tsystem('git checkout -f');\n+\t\tsystem(qw(git checkout -f));\n \t\tdie \"checkout failed: $?\\n\" if $?;\n \t}\n }\n-- \n1.6.5.3\n"},{"id":"131957","messageId":"7v8wbwzgnw.fsf@alter.siamese.dyndns.org","threadId":"22253","inReplyTo":"1263749749-3939-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"Re: [PATCH] cvsimport: modernize and standardize external tool calling","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-17T19:15:47Z","receivedAt":"2010-01-17T19:15:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Walton <bwalton@artsci.utoronto.ca> writes:\n\n> The cvsimport module was mixing old (git-foo) and new (git foo)\n> conventions when calling git tools.  This patch standardizes the\n> calling conventions used in system(), open(), exec() and backticks.\n>\n> Reported-by: Alexander Maier <amaier@opencsw.org>\n> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n> ---\n> This takes into account the feedback from Junio.\n\nHmph...\n\n> -\topen(my $fh, '|-', qw(git-update-index -z --index-info))\n> -\t\tor die \"unable to open git-update-index: $!\";\n> +\topen(my $fh, '|-', 'git update-index -z --index-info')\n> +\t\tor die \"unable to open git update-index: $!\";\n\nI think this change is backwards (and there probably are others).\n\nIt used to use a shell-less one-element-per-argument list form to spawn\nthe process that reads from the pipe, but now you are passing a single\nstring to be split by the shell.\n\nHow about doing this as a two (perhaps three?) patch series instead?\n\n (1) s/git-foo/git foo/ and _nothing else_;\n (2) s/open fh, '|-', 'string'/open fh, '|-', qw(string)/ and\n     s/system 'string'/system qw(string)/.\n"},{"id":"132131","messageId":"1263927790-1872-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"22253","inReplyTo":"7v8wbwzgnw.fsf@alter.siamese.dyndns.org","subject":"[PATCH 1/3] cvsimport: modernize callouts to git subcommands","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-01-19T19:03:08Z","receivedAt":"2010-01-19T19:03:08Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"This patch updates all calling conventions for external git tools.  to\nuse the modern calling convention (eg: git foo instead of git-foo).\nThis is almost entierly a s/git-/git / operation, with deviations only\nas required to keep tests passing.\n\nReported-by: Alexander Maier <amaier@opencsw.org>\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n git-cvsimport.perl |   64 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 32 insertions(+), 32 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex a7d215c..adffa0c 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -609,16 +609,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};\n my %index; # holds filenames of one index per branch\n \n unless (-d $git_dir) {\n-\tsystem(\"git-init\");\n+\tsystem(\"git init\");\n \tdie \"Cannot init the GIT db at $git_tree: $?\\n\" if $?;\n-\tsystem(\"git-read-tree\");\n+\tsystem(\"git read-tree\");\n \tdie \"Cannot init an empty tree: $?\\n\" if $?;\n \n \t$last_branch = $opt_o;\n \t$orig_branch = \"\";\n } else {\n-\topen(F, \"git-symbolic-ref HEAD |\") or\n-\t\tdie \"Cannot run git-symbolic-ref: $!\\n\";\n+\topen(F, \"git symbolic-ref HEAD |\") or\n+\t\tdie \"Cannot run git symbolic-ref: $!\\n\";\n \tchomp ($last_branch = <F>);\n \t$last_branch = basename($last_branch);\n \tclose(F);\n@@ -627,12 +627,12 @@ unless (-d $git_dir) {\n \t\t$last_branch = \"master\";\n \t}\n \t$orig_branch = $last_branch;\n-\t$tip_at_start = `git-rev-parse --verify HEAD`;\n+\t$tip_at_start = `git rev-parse --verify HEAD`;\n \n \t# Get the last import timestamps\n \tmy $fmt = '($ref, $author) = (%(refname), %(author));';\n-\topen(H, \"git-for-each-ref --perl --format='$fmt' $remote |\") or\n-\t\tdie \"Cannot run git-for-each-ref: $!\\n\";\n+\topen(H, \"git for-each-ref --perl --format='$fmt' $remote |\") or\n+\t\tdie \"Cannot run git for-each-ref: $!\\n\";\n \twhile (defined(my $entry = <H>)) {\n \t\tmy ($ref, $author);\n \t\teval($entry) || die \"cannot eval refs list: $@\";\n@@ -687,7 +687,7 @@ unless ($opt_P) {\n \t    print $cvspsfh $_;\n \t}\n \tclose CVSPS;\n-\t$? == 0 or die \"git-cvsimport: fatal: cvsps reported error\\n\";\n+\t$? == 0 or die \"git cvsimport: fatal: cvsps reported error\\n\";\n \tclose $cvspsfh;\n } else {\n \t$cvspsfile = munge_user_filename($opt_P);\n@@ -716,27 +716,27 @@ my $state = 0;\n sub update_index (\\@\\@) {\n \tmy $old = shift;\n \tmy $new = shift;\n-\topen(my $fh, '|-', qw(git-update-index -z --index-info))\n-\t\tor die \"unable to open git-update-index: $!\";\n+\topen(my $fh, '|-', qw(git update-index -z --index-info))\n+\t\tor die \"unable to open git update-index: $!\";\n \tprint $fh\n \t\t(map { \"0 0000000000000000000000000000000000000000\\t$_\\0\" }\n \t\t\t@$old),\n \t\t(map { '100' . sprintf('%o', $_->[0]) . \" $_->[1]\\t$_->[2]\\0\" }\n \t\t\t@$new)\n-\t\tor die \"unable to write to git-update-index: $!\";\n+\t\tor die \"unable to write to git update-index: $!\";\n \tclose $fh\n-\t\tor die \"unable to write to git-update-index: $!\";\n-\t$? and die \"git-update-index reported error: $?\";\n+\t\tor die \"unable to write to git update-index: $!\";\n+\t$? and die \"git update-index reported error: $?\";\n }\n \n sub write_tree () {\n-\topen(my $fh, '-|', qw(git-write-tree))\n-\t\tor die \"unable to open git-write-tree: $!\";\n+\topen(my $fh, '-|', \"git write-tree\")\n+\t\tor die \"unable to open git write-tree: $!\";\n \tchomp(my $tree = <$fh>);\n \tis_sha1($tree)\n \t\tor die \"Cannot get tree id ($tree): $!\";\n \tclose($fh)\n-\t\tor die \"Error running git-write-tree: $?\\n\";\n+\t\tor die \"Error running git write-tree: $?\\n\";\n \tprint \"Tree ID $tree\\n\" if $opt_v;\n \treturn $tree;\n }\n@@ -751,7 +751,7 @@ sub commit {\n \tif ($branch eq $opt_o && !$index{branch} &&\n \t\t!get_headref(\"$remote/$branch\")) {\n \t    # looks like an initial commit\n-\t    # use the index primed by git-init\n+\t    # use the index primed by git init\n \t    $ENV{GIT_INDEX_FILE} = \"$git_dir/index\";\n \t    $index{$branch} = \"$git_dir/index\";\n \t} else {\n@@ -761,9 +761,9 @@ sub commit {\n \t\t$index{$branch} = tmpnam();\n \t\t$ENV{GIT_INDEX_FILE} = $index{$branch};\n \t\tif ($ancestor) {\n-\t\t    system(\"git-read-tree\", \"$remote/$ancestor\");\n+\t\t    system(\"git\", \"read-tree\", \"$remote/$ancestor\");\n \t\t} else {\n-\t\t    system(\"git-read-tree\", \"$remote/$branch\");\n+\t\t    system(\"git\", \"read-tree\", \"$remote/$branch\");\n \t\t}\n \t\tdie \"read-tree failed: $?\\n\" if $?;\n \t    }\n@@ -798,7 +798,7 @@ sub commit {\n \t$ENV{GIT_COMMITTER_EMAIL} = $author_email;\n \t$ENV{GIT_COMMITTER_DATE} = $commit_date;\n \tmy $pid = open2(my $commit_read, my $commit_write,\n-\t\t'git-commit-tree', $tree, @commit_args);\n+\t\t'git', 'commit-tree', $tree, @commit_args);\n \n \t# compatibility with git2cvs\n \tsubstr($logmsg,32767) = \"\" if length($logmsg) > 32767;\n@@ -811,7 +811,7 @@ sub commit {\n \t}\n \n \tprint($commit_write \"$logmsg\\n\") && close($commit_write)\n-\t\tor die \"Error writing to git-commit-tree: $!\\n\";\n+\t\tor die \"Error writing to git commit-tree: $!\\n\";\n \n \tprint \"Committed patch $patchset ($branch $commit_date)\\n\" if $opt_v;\n \tchomp(my $cid = <$commit_read>);\n@@ -820,9 +820,9 @@ sub commit {\n \tclose($commit_read);\n \n \twaitpid($pid,0);\n-\tdie \"Error running git-commit-tree: $?\\n\" if $?;\n+\tdie \"Error running git commit-tree: $?\\n\" if $?;\n \n-\tsystem('git-update-ref', \"$remote/$branch\", $cid) == 0\n+\tsystem('git' , 'update-ref', \"$remote/$branch\", $cid) == 0\n \t\tor die \"Cannot write branch $branch for update: $!\\n\";\n \n \tif ($tag) {\n@@ -832,7 +832,7 @@ sub commit {\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n \t\t$xtag =~ s/\\[//g;\n \n-\t\tsystem('git-tag', '-f', $xtag, $cid) == 0\n+\t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n \n \t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n@@ -969,7 +969,7 @@ while (<CVS>) {\n \t\t\tmy $pid = open(my $F, '-|');\n \t\t\tdie $! unless defined $pid;\n \t\t\tif (!$pid) {\n-\t\t\t    exec(\"git-hash-object\", \"-w\", $tmpname)\n+\t\t\t    exec(\"git\", \"hash-object\", \"-w\", $tmpname)\n \t\t\t\tor die \"Cannot create object: $!\\n\";\n \t\t\t}\n \t\t\tmy $sha = <$F>;\n@@ -1013,7 +1013,7 @@ unless ($opt_P) {\n # The heuristic of repacking every 1024 commits can leave a\n # lot of unpacked data.  If there is more than 1MB worth of\n # not-packed objects, repack once more.\n-my $line = `git-count-objects`;\n+my $line = `git count-objects`;\n if ($line =~ /^(\\d+) objects, (\\d+) kilobytes$/) {\n   my ($n_objects, $kb) = ($1, $2);\n   1024 < $kb\n@@ -1038,26 +1038,26 @@ if ($orig_branch) {\n \tif ($opt_i) {\n \t\texit 0;\n \t}\n-\tmy $tip_at_end = `git-rev-parse --verify HEAD`;\n+\tmy $tip_at_end = `git rev-parse --verify HEAD`;\n \tif ($tip_at_start ne $tip_at_end) {\n \t\tfor ($tip_at_start, $tip_at_end) { chomp; }\n \t\tprint \"Fetched into the current branch.\\n\" if $opt_v;\n-\t\tsystem(qw(git-read-tree -u -m),\n+\t\tsystem(qw(git read-tree -u -m),\n \t\t       $tip_at_start, $tip_at_end);\n \t\tdie \"Fast-forward update failed: $?\\n\" if $?;\n \t}\n \telse {\n-\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$opt_o\");\n+\t\tsystem(qw(git merge cvsimport HEAD), \"$remote/$opt_o\");\n \t\tdie \"Could not merge $opt_o into the current branch.\\n\" if $?;\n \t}\n } else {\n \t$orig_branch = \"master\";\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n-\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n+\tsystem(\"git\", \"update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n \t\tunless defined get_headref('refs/heads/master');\n-\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n+\tsystem(\"git\", \"symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n \t\tif ($opt_r && $opt_o ne 'HEAD');\n-\tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n+\tsystem('git', 'update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n \t\tsystem('git checkout -f');\n \t\tdie \"checkout failed: $?\\n\" if $?;\n-- \n1.6.5.3\n"},{"id":"132132","messageId":"1263927790-1872-2-git-send-email-bwalton@artsci.utoronto.ca","threadId":"22253","inReplyTo":"1263927790-1872-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH 2/3] cvsimport: standarize open() calls to external git tools","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-01-19T19:03:09Z","receivedAt":"2010-01-19T19:03:09Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"This patch standardizes calls to open() where git modules are used as\npart of a pipeline.  Instead of open(X, \"git foo ... |)\", use open(X,\n\"-|\", qw(git foo ...)).  This standarization should see all calls made\nwithout the use of an 'sh -c' process to split the arguments.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n git-cvsimport.perl |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex adffa0c..e838c2e 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -617,7 +617,7 @@ unless (-d $git_dir) {\n \t$last_branch = $opt_o;\n \t$orig_branch = \"\";\n } else {\n-\topen(F, \"git symbolic-ref HEAD |\") or\n+\topen(F, \"-|\", qw(git symbolic-ref HEAD)) or\n \t\tdie \"Cannot run git symbolic-ref: $!\\n\";\n \tchomp ($last_branch = <F>);\n \t$last_branch = basename($last_branch);\n@@ -631,8 +631,8 @@ unless (-d $git_dir) {\n \n \t# Get the last import timestamps\n \tmy $fmt = '($ref, $author) = (%(refname), %(author));';\n-\topen(H, \"git for-each-ref --perl --format='$fmt' $remote |\") or\n-\t\tdie \"Cannot run git for-each-ref: $!\\n\";\n+\tmy @cmd = ('git', 'for-each-ref', '--perl', \"--format=$fmt\", $remote);\n+\topen(H, \"-|\", @cmd) or die \"Cannot run git for-each-ref: $!\\n\";\n \twhile (defined(my $entry = <H>)) {\n \t\tmy ($ref, $author);\n \t\teval($entry) || die \"cannot eval refs list: $@\";\n@@ -730,7 +730,7 @@ sub update_index (\\@\\@) {\n }\n \n sub write_tree () {\n-\topen(my $fh, '-|', \"git write-tree\")\n+\topen(my $fh, '-|', qw(git write-tree))\n \t\tor die \"unable to open git write-tree: $!\";\n \tchomp(my $tree = <$fh>);\n \tis_sha1($tree)\n-- \n1.6.5.3\n"},{"id":"132133","messageId":"1263927790-1872-3-git-send-email-bwalton@artsci.utoronto.ca","threadId":"22253","inReplyTo":"1263927790-1872-2-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH 3/3] cvsimport: standarize system() calls to external git tools","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-01-19T19:03:10Z","receivedAt":"2010-01-19T19:03:10Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"This patch standardizes calls to system() where.  Instead of\nsystem(\"git foo ... \"), use system(qw(git foo ...)).  This\nstandarization should see all calls made without the use of an 'sh -c'\nprocess to split the arguments.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n git-cvsimport.perl |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex e838c2e..4853bf7 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -609,9 +609,9 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};\n my %index; # holds filenames of one index per branch\n \n unless (-d $git_dir) {\n-\tsystem(\"git init\");\n+\tsystem(qw(git init));\n \tdie \"Cannot init the GIT db at $git_tree: $?\\n\" if $?;\n-\tsystem(\"git read-tree\");\n+\tsystem(qw(git read-tree));\n \tdie \"Cannot init an empty tree: $?\\n\" if $?;\n \n \t$last_branch = $opt_o;\n@@ -993,7 +993,7 @@ while (<CVS>) {\n \t\t}\n \t\tcommit();\n \t\tif (($commitcount & 1023) == 0) {\n-\t\t\tsystem(\"git repack -a -d\");\n+\t\t\tsystem(qw(git repack -a -d));\n \t\t}\n \t\t$state = 1;\n \t} elsif ($state == 11 and /^-+$/) {\n@@ -1017,7 +1017,7 @@ my $line = `git count-objects`;\n if ($line =~ /^(\\d+) objects, (\\d+) kilobytes$/) {\n   my ($n_objects, $kb) = ($1, $2);\n   1024 < $kb\n-    and system(\"git repack -a -d\");\n+    and system(qw(git repack -a -d));\n }\n \n foreach my $git_index (values %index) {\n@@ -1059,7 +1059,7 @@ if ($orig_branch) {\n \t\tif ($opt_r && $opt_o ne 'HEAD');\n \tsystem('git', 'update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n-\t\tsystem('git checkout -f');\n+\t\tsystem(qw(git checkout -f));\n \t\tdie \"checkout failed: $?\\n\" if $?;\n \t}\n }\n-- \n1.6.5.3\n"}]}