@matheusbsbs / matheus-bagliano / commits / 640d9d0873
Fork 0

cvsimport: modernize callouts to git subcommands

This patch updates all calling conventions for external git tools. to use the modern calling convention (eg: git foo instead of git-foo). This is almost entierly a s/git-/git / operation, with deviations only as required to keep tests passing. Reported-by: Alexander Maier <amaier@opencsw.org> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Walton committed Jan 19, 2010 at 14:03 UTC 640d9d08738db4380c2f856d60ac0a2ceb496c2f
1 file changed +32 -32
git-cvsimport.perl
+32 -32
@@ -609,16 +609,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
609 my %index; # holds filenames of one index per branch
610
611 unless (-d $git_dir) {
612 - system("git-init");
612 + system("git init");
613 die "Cannot init the GIT db at $git_tree: $?\n" if $?;
614 - system("git-read-tree");
614 + system("git read-tree");
615 die "Cannot init an empty tree: $?\n" if $?;
616
617 $last_branch = $opt_o;
618 $orig_branch = "";
619 } else {
620 - open(F, "git-symbolic-ref HEAD |") or
621 - die "Cannot run git-symbolic-ref: $!\n";
620 + open(F, "git symbolic-ref HEAD |") or
621 + die "Cannot run git symbolic-ref: $!\n";
622 chomp ($last_branch = <F>);
623 $last_branch = basename($last_branch);
624 close(F);
@@ -627,12 +627,12 @@ unless (-d $git_dir) {
627 $last_branch = "master";
628 }
629 $orig_branch = $last_branch;
630 - $tip_at_start = `git-rev-parse --verify HEAD`;
630 + $tip_at_start = `git rev-parse --verify HEAD`;
631
632 # Get the last import timestamps
633 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 + open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
635 + die "Cannot run git for-each-ref: $!\n";
636 while (defined(my $entry = <H>)) {
637 my ($ref, $author);
638 eval($entry) || die "cannot eval refs list: $@";
@@ -687,7 +687,7 @@ unless ($opt_P) {
687 print $cvspsfh $_;
688 }
689 close CVSPS;
690 - $? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
690 + $? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
691 close $cvspsfh;
692 } else {
693 $cvspsfile = munge_user_filename($opt_P);
@@ -716,27 +716,27 @@ my $state = 0;
716 sub update_index (\@\@) {
717 my $old = shift;
718 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: $!";
721 print $fh
722 (map { "0 0000000000000000000000000000000000000000\t$_\0" }
723 @$old),
724 (map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
725 @$new)
726 - or die "unable to write to git-update-index: $!";
726 + or die "unable to write to git update-index: $!";
727 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: $?";
730 }
731
732 sub write_tree () {
733 - open(my $fh, '-|', qw(git-write-tree))
734 - or die "unable to open git-write-tree: $!";
733 + open(my $fh, '-|', "git write-tree")
734 + or die "unable to open git write-tree: $!";
735 chomp(my $tree = <$fh>);
736 is_sha1($tree)
737 or die "Cannot get tree id ($tree): $!";
738 close($fh)
739 - or die "Error running git-write-tree: $?\n";
739 + or die "Error running git write-tree: $?\n";
740 print "Tree ID $tree\n" if $opt_v;
741 return $tree;
742 }
@@ -751,7 +751,7 @@ sub commit {
751 if ($branch eq $opt_o && !$index{branch} &&
752 !get_headref("$remote/$branch")) {
753 # looks like an initial commit
754 - # use the index primed by git-init
754 + # use the index primed by git init
755 $ENV{GIT_INDEX_FILE} = "$git_dir/index";
756 $index{$branch} = "$git_dir/index";
757 } else {
@@ -761,9 +761,9 @@ sub commit {
761 $index{$branch} = tmpnam();
762 $ENV{GIT_INDEX_FILE} = $index{$branch};
763 if ($ancestor) {
764 - system("git-read-tree", "$remote/$ancestor");
764 + system("git", "read-tree", "$remote/$ancestor");
765 } else {
766 - system("git-read-tree", "$remote/$branch");
766 + system("git", "read-tree", "$remote/$branch");
767 }
768 die "read-tree failed: $?\n" if $?;
769 }
@@ -798,7 +798,7 @@ sub commit {
798 $ENV{GIT_COMMITTER_EMAIL} = $author_email;
799 $ENV{GIT_COMMITTER_DATE} = $commit_date;
800 my $pid = open2(my $commit_read, my $commit_write,
801 - 'git-commit-tree', $tree, @commit_args);
801 + 'git', 'commit-tree', $tree, @commit_args);
802
803 # compatibility with git2cvs
804 substr($logmsg,32767) = "" if length($logmsg) > 32767;
@@ -811,7 +811,7 @@ sub commit {
811 }
812
813 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";
815
816 print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
817 chomp(my $cid = <$commit_read>);
@@ -820,9 +820,9 @@ sub commit {
820 close($commit_read);
821
822 waitpid($pid,0);
823 - die "Error running git-commit-tree: $?\n" if $?;
823 + die "Error running git commit-tree: $?\n" if $?;
824
825 - system('git-update-ref', "$remote/$branch", $cid) == 0
825 + system('git' , 'update-ref', "$remote/$branch", $cid) == 0
826 or die "Cannot write branch $branch for update: $!\n";
827
828 if ($tag) {
@@ -832,7 +832,7 @@ sub commit {
832 $xtag =~ s/[\/]/$opt_s/g;
833 $xtag =~ s/\[//g;
834
835 - system('git-tag', '-f', $xtag, $cid) == 0
835 + system('git' , 'tag', '-f', $xtag, $cid) == 0
836 or die "Cannot create tag $xtag: $!\n";
837
838 print "Created tag '$xtag' on '$branch'\n" if $opt_v;
@@ -969,7 +969,7 @@ while (<CVS>) {
969 my $pid = open(my $F, '-|');
970 die $! unless defined $pid;
971 if (!$pid) {
972 - exec("git-hash-object", "-w", $tmpname)
972 + exec("git", "hash-object", "-w", $tmpname)
973 or die "Cannot create object: $!\n";
974 }
975 my $sha = <$F>;
@@ -1013,7 +1013,7 @@ unless ($opt_P) {
1013 # The heuristic of repacking every 1024 commits can leave a
1014 # lot of unpacked data. If there is more than 1MB worth of
1015 # not-packed objects, repack once more.
1016 -my $line = `git-count-objects`;
1016 +my $line = `git count-objects`;
1017 if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
1018 my ($n_objects, $kb) = ($1, $2);
1019 1024 < $kb
@@ -1038,26 +1038,26 @@ if ($orig_branch) {
1038 if ($opt_i) {
1039 exit 0;
1040 }
1041 - my $tip_at_end = `git-rev-parse --verify HEAD`;
1041 + my $tip_at_end = `git rev-parse --verify HEAD`;
1042 if ($tip_at_start ne $tip_at_end) {
1043 for ($tip_at_start, $tip_at_end) { chomp; }
1044 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),
1046 $tip_at_start, $tip_at_end);
1047 die "Fast-forward update failed: $?\n" if $?;
1048 }
1049 else {
1050 - system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
1050 + system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
1051 die "Could not merge $opt_o into the current branch.\n" if $?;
1052 }
1053 } else {
1054 $orig_branch = "master";
1055 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")
1057 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")
1059 if ($opt_r && $opt_o ne 'HEAD');
1060 - system('git-update-ref', 'HEAD', "$orig_branch");
1060 + system('git', 'update-ref', 'HEAD', "$orig_branch");
1061 unless ($opt_i) {
1062 system('git checkout -f');
1063 die "checkout failed: $?\n" if $?;