Skip to content

Commit d4556c4

Browse files
committed
Merge branch 'bw/cvsimport'
* bw/cvsimport: cvsimport: standarize system() calls to external git tools cvsimport: standarize open() calls to external git tools cvsimport: modernize callouts to git subcommands
2 parents b3ce9a0 + 91fe732 commit d4556c4

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

git-cvsimport.perl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,16 @@ sub munge_user_filename {
609609
my %index; # holds filenames of one index per branch
610610

611611
unless (-d $git_dir) {
612-
system("git-init");
612+
system(qw(git init));
613613
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
614-
system("git-read-tree");
614+
system(qw(git read-tree));
615615
die "Cannot init an empty tree: $?\n" if $?;
616616

617617
$last_branch = $opt_o;
618618
$orig_branch = "";
619619
} else {
620-
open(F, "git-symbolic-ref HEAD |") or
621-
die "Cannot run git-symbolic-ref: $!\n";
620+
open(F, "-|", qw(git symbolic-ref HEAD)) or
621+
die "Cannot run git symbolic-ref: $!\n";
622622
chomp ($last_branch = <F>);
623623
$last_branch = basename($last_branch);
624624
close(F);
@@ -627,12 +627,12 @@ sub munge_user_filename {
627627
$last_branch = "master";
628628
}
629629
$orig_branch = $last_branch;
630-
$tip_at_start = `git-rev-parse --verify HEAD`;
630+
$tip_at_start = `git rev-parse --verify HEAD`;
631631

632632
# Get the last import timestamps
633633
my $fmt = '($ref, $author) = (%(refname), %(author));';
634-
open(H, "git-for-each-ref --perl --format='$fmt' $remote |") or
635-
die "Cannot run git-for-each-ref: $!\n";
634+
my @cmd = ('git', 'for-each-ref', '--perl', "--format=$fmt", $remote);
635+
open(H, "-|", @cmd) or die "Cannot run git for-each-ref: $!\n";
636636
while (defined(my $entry = <H>)) {
637637
my ($ref, $author);
638638
eval($entry) || die "cannot eval refs list: $@";
@@ -687,7 +687,7 @@ sub munge_user_filename {
687687
print $cvspsfh $_;
688688
}
689689
close CVSPS;
690-
$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
690+
$? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
691691
close $cvspsfh;
692692
} else {
693693
$cvspsfile = munge_user_filename($opt_P);
@@ -716,27 +716,27 @@ sub munge_user_filename {
716716
sub update_index (\@\@) {
717717
my $old = shift;
718718
my $new = shift;
719-
open(my $fh, '|-', qw(git-update-index -z --index-info))
720-
or die "unable to open git-update-index: $!";
719+
open(my $fh, '|-', qw(git update-index -z --index-info))
720+
or die "unable to open git update-index: $!";
721721
print $fh
722722
(map { "0 0000000000000000000000000000000000000000\t$_\0" }
723723
@$old),
724724
(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
725725
@$new)
726-
or die "unable to write to git-update-index: $!";
726+
or die "unable to write to git update-index: $!";
727727
close $fh
728-
or die "unable to write to git-update-index: $!";
729-
$? and die "git-update-index reported error: $?";
728+
or die "unable to write to git update-index: $!";
729+
$? and die "git update-index reported error: $?";
730730
}
731731

732732
sub write_tree () {
733-
open(my $fh, '-|', qw(git-write-tree))
734-
or die "unable to open git-write-tree: $!";
733+
open(my $fh, '-|', qw(git write-tree))
734+
or die "unable to open git write-tree: $!";
735735
chomp(my $tree = <$fh>);
736736
is_sha1($tree)
737737
or die "Cannot get tree id ($tree): $!";
738738
close($fh)
739-
or die "Error running git-write-tree: $?\n";
739+
or die "Error running git write-tree: $?\n";
740740
print "Tree ID $tree\n" if $opt_v;
741741
return $tree;
742742
}
@@ -751,7 +751,7 @@ sub commit {
751751
if ($branch eq $opt_o && !$index{branch} &&
752752
!get_headref("$remote/$branch")) {
753753
# looks like an initial commit
754-
# use the index primed by git-init
754+
# use the index primed by git init
755755
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
756756
$index{$branch} = "$git_dir/index";
757757
} else {
@@ -761,9 +761,9 @@ sub commit {
761761
$index{$branch} = tmpnam();
762762
$ENV{GIT_INDEX_FILE} = $index{$branch};
763763
if ($ancestor) {
764-
system("git-read-tree", "$remote/$ancestor");
764+
system("git", "read-tree", "$remote/$ancestor");
765765
} else {
766-
system("git-read-tree", "$remote/$branch");
766+
system("git", "read-tree", "$remote/$branch");
767767
}
768768
die "read-tree failed: $?\n" if $?;
769769
}
@@ -798,7 +798,7 @@ sub commit {
798798
$ENV{GIT_COMMITTER_EMAIL} = $author_email;
799799
$ENV{GIT_COMMITTER_DATE} = $commit_date;
800800
my $pid = open2(my $commit_read, my $commit_write,
801-
'git-commit-tree', $tree, @commit_args);
801+
'git', 'commit-tree', $tree, @commit_args);
802802

803803
# compatibility with git2cvs
804804
substr($logmsg,32767) = "" if length($logmsg) > 32767;
@@ -811,7 +811,7 @@ sub commit {
811811
}
812812

813813
print($commit_write "$logmsg\n") && close($commit_write)
814-
or die "Error writing to git-commit-tree: $!\n";
814+
or die "Error writing to git commit-tree: $!\n";
815815

816816
print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
817817
chomp(my $cid = <$commit_read>);
@@ -820,9 +820,9 @@ sub commit {
820820
close($commit_read);
821821

822822
waitpid($pid,0);
823-
die "Error running git-commit-tree: $?\n" if $?;
823+
die "Error running git commit-tree: $?\n" if $?;
824824

825-
system('git-update-ref', "$remote/$branch", $cid) == 0
825+
system('git' , 'update-ref', "$remote/$branch", $cid) == 0
826826
or die "Cannot write branch $branch for update: $!\n";
827827

828828
if ($tag) {
@@ -832,7 +832,7 @@ sub commit {
832832
$xtag =~ s/[\/]/$opt_s/g;
833833
$xtag =~ s/\[//g;
834834

835-
system('git-tag', '-f', $xtag, $cid) == 0
835+
system('git' , 'tag', '-f', $xtag, $cid) == 0
836836
or die "Cannot create tag $xtag: $!\n";
837837

838838
print "Created tag '$xtag' on '$branch'\n" if $opt_v;
@@ -969,7 +969,7 @@ sub commit {
969969
my $pid = open(my $F, '-|');
970970
die $! unless defined $pid;
971971
if (!$pid) {
972-
exec("git-hash-object", "-w", $tmpname)
972+
exec("git", "hash-object", "-w", $tmpname)
973973
or die "Cannot create object: $!\n";
974974
}
975975
my $sha = <$F>;
@@ -993,7 +993,7 @@ sub commit {
993993
}
994994
commit();
995995
if (($commitcount & 1023) == 0) {
996-
system("git repack -a -d");
996+
system(qw(git repack -a -d));
997997
}
998998
$state = 1;
999999
} elsif ($state == 11 and /^-+$/) {
@@ -1013,11 +1013,11 @@ sub commit {
10131013
# The heuristic of repacking every 1024 commits can leave a
10141014
# lot of unpacked data. If there is more than 1MB worth of
10151015
# not-packed objects, repack once more.
1016-
my $line = `git-count-objects`;
1016+
my $line = `git count-objects`;
10171017
if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
10181018
my ($n_objects, $kb) = ($1, $2);
10191019
1024 < $kb
1020-
and system("git repack -a -d");
1020+
and system(qw(git repack -a -d));
10211021
}
10221022
10231023
foreach my $git_index (values %index) {
@@ -1038,28 +1038,28 @@ sub commit {
10381038
if ($opt_i) {
10391039
exit 0;
10401040
}
1041-
my $tip_at_end = `git-rev-parse --verify HEAD`;
1041+
my $tip_at_end = `git rev-parse --verify HEAD`;
10421042
if ($tip_at_start ne $tip_at_end) {
10431043
for ($tip_at_start, $tip_at_end) { chomp; }
10441044
print "Fetched into the current branch.\n" if $opt_v;
1045-
system(qw(git-read-tree -u -m),
1045+
system(qw(git read-tree -u -m),
10461046
$tip_at_start, $tip_at_end);
10471047
die "Fast-forward update failed: $?\n" if $?;
10481048
}
10491049
else {
1050-
system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
1050+
system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
10511051
die "Could not merge $opt_o into the current branch.\n" if $?;
10521052
}
10531053
} else {
10541054
$orig_branch = "master";
10551055
print "DONE; creating $orig_branch branch\n" if $opt_v;
1056-
system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
1056+
system("git", "update-ref", "refs/heads/master", "$remote/$opt_o")
10571057
unless defined get_headref('refs/heads/master');
1058-
system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
1058+
system("git", "symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
10591059
if ($opt_r && $opt_o ne 'HEAD');
1060-
system('git-update-ref', 'HEAD', "$orig_branch");
1060+
system('git', 'update-ref', 'HEAD', "$orig_branch");
10611061
unless ($opt_i) {
1062-
system('git checkout -f');
1062+
system(qw(git checkout -f));
10631063
die "checkout failed: $?\n" if $?;
10641064
}
10651065
}

0 commit comments

Comments
 (0)