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>
This commit is contained in:
parent
d07430f98c
commit
640d9d0873
@ -609,16 +609,16 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
|
|||||||
my %index; # holds filenames of one index per branch
|
my %index; # holds filenames of one index per branch
|
||||||
|
|
||||||
unless (-d $git_dir) {
|
unless (-d $git_dir) {
|
||||||
system("git-init");
|
system("git init");
|
||||||
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
|
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
|
||||||
system("git-read-tree");
|
system("git read-tree");
|
||||||
die "Cannot init an empty tree: $?\n" if $?;
|
die "Cannot init an empty tree: $?\n" if $?;
|
||||||
|
|
||||||
$last_branch = $opt_o;
|
$last_branch = $opt_o;
|
||||||
$orig_branch = "";
|
$orig_branch = "";
|
||||||
} else {
|
} else {
|
||||||
open(F, "git-symbolic-ref HEAD |") or
|
open(F, "git symbolic-ref HEAD |") or
|
||||||
die "Cannot run git-symbolic-ref: $!\n";
|
die "Cannot run git symbolic-ref: $!\n";
|
||||||
chomp ($last_branch = <F>);
|
chomp ($last_branch = <F>);
|
||||||
$last_branch = basename($last_branch);
|
$last_branch = basename($last_branch);
|
||||||
close(F);
|
close(F);
|
||||||
@ -627,12 +627,12 @@ unless (-d $git_dir) {
|
|||||||
$last_branch = "master";
|
$last_branch = "master";
|
||||||
}
|
}
|
||||||
$orig_branch = $last_branch;
|
$orig_branch = $last_branch;
|
||||||
$tip_at_start = `git-rev-parse --verify HEAD`;
|
$tip_at_start = `git rev-parse --verify HEAD`;
|
||||||
|
|
||||||
# Get the last import timestamps
|
# Get the last import timestamps
|
||||||
my $fmt = '($ref, $author) = (%(refname), %(author));';
|
my $fmt = '($ref, $author) = (%(refname), %(author));';
|
||||||
open(H, "git-for-each-ref --perl --format='$fmt' $remote |") or
|
open(H, "git for-each-ref --perl --format='$fmt' $remote |") or
|
||||||
die "Cannot run git-for-each-ref: $!\n";
|
die "Cannot run git for-each-ref: $!\n";
|
||||||
while (defined(my $entry = <H>)) {
|
while (defined(my $entry = <H>)) {
|
||||||
my ($ref, $author);
|
my ($ref, $author);
|
||||||
eval($entry) || die "cannot eval refs list: $@";
|
eval($entry) || die "cannot eval refs list: $@";
|
||||||
@ -687,7 +687,7 @@ unless ($opt_P) {
|
|||||||
print $cvspsfh $_;
|
print $cvspsfh $_;
|
||||||
}
|
}
|
||||||
close CVSPS;
|
close CVSPS;
|
||||||
$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
|
$? == 0 or die "git cvsimport: fatal: cvsps reported error\n";
|
||||||
close $cvspsfh;
|
close $cvspsfh;
|
||||||
} else {
|
} else {
|
||||||
$cvspsfile = munge_user_filename($opt_P);
|
$cvspsfile = munge_user_filename($opt_P);
|
||||||
@ -716,27 +716,27 @@ my $state = 0;
|
|||||||
sub update_index (\@\@) {
|
sub update_index (\@\@) {
|
||||||
my $old = shift;
|
my $old = shift;
|
||||||
my $new = shift;
|
my $new = shift;
|
||||||
open(my $fh, '|-', qw(git-update-index -z --index-info))
|
open(my $fh, '|-', qw(git update-index -z --index-info))
|
||||||
or die "unable to open git-update-index: $!";
|
or die "unable to open git update-index: $!";
|
||||||
print $fh
|
print $fh
|
||||||
(map { "0 0000000000000000000000000000000000000000\t$_\0" }
|
(map { "0 0000000000000000000000000000000000000000\t$_\0" }
|
||||||
@$old),
|
@$old),
|
||||||
(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
|
(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
|
||||||
@$new)
|
@$new)
|
||||||
or die "unable to write to git-update-index: $!";
|
or die "unable to write to git update-index: $!";
|
||||||
close $fh
|
close $fh
|
||||||
or die "unable to write to git-update-index: $!";
|
or die "unable to write to git update-index: $!";
|
||||||
$? and die "git-update-index reported error: $?";
|
$? and die "git update-index reported error: $?";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub write_tree () {
|
sub write_tree () {
|
||||||
open(my $fh, '-|', qw(git-write-tree))
|
open(my $fh, '-|', "git write-tree")
|
||||||
or die "unable to open git-write-tree: $!";
|
or die "unable to open git write-tree: $!";
|
||||||
chomp(my $tree = <$fh>);
|
chomp(my $tree = <$fh>);
|
||||||
is_sha1($tree)
|
is_sha1($tree)
|
||||||
or die "Cannot get tree id ($tree): $!";
|
or die "Cannot get tree id ($tree): $!";
|
||||||
close($fh)
|
close($fh)
|
||||||
or die "Error running git-write-tree: $?\n";
|
or die "Error running git write-tree: $?\n";
|
||||||
print "Tree ID $tree\n" if $opt_v;
|
print "Tree ID $tree\n" if $opt_v;
|
||||||
return $tree;
|
return $tree;
|
||||||
}
|
}
|
||||||
@ -751,7 +751,7 @@ sub commit {
|
|||||||
if ($branch eq $opt_o && !$index{branch} &&
|
if ($branch eq $opt_o && !$index{branch} &&
|
||||||
!get_headref("$remote/$branch")) {
|
!get_headref("$remote/$branch")) {
|
||||||
# looks like an initial commit
|
# looks like an initial commit
|
||||||
# use the index primed by git-init
|
# use the index primed by git init
|
||||||
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
|
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
|
||||||
$index{$branch} = "$git_dir/index";
|
$index{$branch} = "$git_dir/index";
|
||||||
} else {
|
} else {
|
||||||
@ -761,9 +761,9 @@ sub commit {
|
|||||||
$index{$branch} = tmpnam();
|
$index{$branch} = tmpnam();
|
||||||
$ENV{GIT_INDEX_FILE} = $index{$branch};
|
$ENV{GIT_INDEX_FILE} = $index{$branch};
|
||||||
if ($ancestor) {
|
if ($ancestor) {
|
||||||
system("git-read-tree", "$remote/$ancestor");
|
system("git", "read-tree", "$remote/$ancestor");
|
||||||
} else {
|
} else {
|
||||||
system("git-read-tree", "$remote/$branch");
|
system("git", "read-tree", "$remote/$branch");
|
||||||
}
|
}
|
||||||
die "read-tree failed: $?\n" if $?;
|
die "read-tree failed: $?\n" if $?;
|
||||||
}
|
}
|
||||||
@ -798,7 +798,7 @@ sub commit {
|
|||||||
$ENV{GIT_COMMITTER_EMAIL} = $author_email;
|
$ENV{GIT_COMMITTER_EMAIL} = $author_email;
|
||||||
$ENV{GIT_COMMITTER_DATE} = $commit_date;
|
$ENV{GIT_COMMITTER_DATE} = $commit_date;
|
||||||
my $pid = open2(my $commit_read, my $commit_write,
|
my $pid = open2(my $commit_read, my $commit_write,
|
||||||
'git-commit-tree', $tree, @commit_args);
|
'git', 'commit-tree', $tree, @commit_args);
|
||||||
|
|
||||||
# compatibility with git2cvs
|
# compatibility with git2cvs
|
||||||
substr($logmsg,32767) = "" if length($logmsg) > 32767;
|
substr($logmsg,32767) = "" if length($logmsg) > 32767;
|
||||||
@ -811,7 +811,7 @@ sub commit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print($commit_write "$logmsg\n") && close($commit_write)
|
print($commit_write "$logmsg\n") && close($commit_write)
|
||||||
or die "Error writing to git-commit-tree: $!\n";
|
or die "Error writing to git commit-tree: $!\n";
|
||||||
|
|
||||||
print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
|
print "Committed patch $patchset ($branch $commit_date)\n" if $opt_v;
|
||||||
chomp(my $cid = <$commit_read>);
|
chomp(my $cid = <$commit_read>);
|
||||||
@ -820,9 +820,9 @@ sub commit {
|
|||||||
close($commit_read);
|
close($commit_read);
|
||||||
|
|
||||||
waitpid($pid,0);
|
waitpid($pid,0);
|
||||||
die "Error running git-commit-tree: $?\n" if $?;
|
die "Error running git commit-tree: $?\n" if $?;
|
||||||
|
|
||||||
system('git-update-ref', "$remote/$branch", $cid) == 0
|
system('git' , 'update-ref', "$remote/$branch", $cid) == 0
|
||||||
or die "Cannot write branch $branch for update: $!\n";
|
or die "Cannot write branch $branch for update: $!\n";
|
||||||
|
|
||||||
if ($tag) {
|
if ($tag) {
|
||||||
@ -832,7 +832,7 @@ sub commit {
|
|||||||
$xtag =~ s/[\/]/$opt_s/g;
|
$xtag =~ s/[\/]/$opt_s/g;
|
||||||
$xtag =~ s/\[//g;
|
$xtag =~ s/\[//g;
|
||||||
|
|
||||||
system('git-tag', '-f', $xtag, $cid) == 0
|
system('git' , 'tag', '-f', $xtag, $cid) == 0
|
||||||
or die "Cannot create tag $xtag: $!\n";
|
or die "Cannot create tag $xtag: $!\n";
|
||||||
|
|
||||||
print "Created tag '$xtag' on '$branch'\n" if $opt_v;
|
print "Created tag '$xtag' on '$branch'\n" if $opt_v;
|
||||||
@ -969,7 +969,7 @@ while (<CVS>) {
|
|||||||
my $pid = open(my $F, '-|');
|
my $pid = open(my $F, '-|');
|
||||||
die $! unless defined $pid;
|
die $! unless defined $pid;
|
||||||
if (!$pid) {
|
if (!$pid) {
|
||||||
exec("git-hash-object", "-w", $tmpname)
|
exec("git", "hash-object", "-w", $tmpname)
|
||||||
or die "Cannot create object: $!\n";
|
or die "Cannot create object: $!\n";
|
||||||
}
|
}
|
||||||
my $sha = <$F>;
|
my $sha = <$F>;
|
||||||
@ -1013,7 +1013,7 @@ unless ($opt_P) {
|
|||||||
# The heuristic of repacking every 1024 commits can leave a
|
# The heuristic of repacking every 1024 commits can leave a
|
||||||
# lot of unpacked data. If there is more than 1MB worth of
|
# lot of unpacked data. If there is more than 1MB worth of
|
||||||
# not-packed objects, repack once more.
|
# not-packed objects, repack once more.
|
||||||
my $line = `git-count-objects`;
|
my $line = `git count-objects`;
|
||||||
if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
|
if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
|
||||||
my ($n_objects, $kb) = ($1, $2);
|
my ($n_objects, $kb) = ($1, $2);
|
||||||
1024 < $kb
|
1024 < $kb
|
||||||
@ -1038,26 +1038,26 @@ if ($orig_branch) {
|
|||||||
if ($opt_i) {
|
if ($opt_i) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
my $tip_at_end = `git-rev-parse --verify HEAD`;
|
my $tip_at_end = `git rev-parse --verify HEAD`;
|
||||||
if ($tip_at_start ne $tip_at_end) {
|
if ($tip_at_start ne $tip_at_end) {
|
||||||
for ($tip_at_start, $tip_at_end) { chomp; }
|
for ($tip_at_start, $tip_at_end) { chomp; }
|
||||||
print "Fetched into the current branch.\n" if $opt_v;
|
print "Fetched into the current branch.\n" if $opt_v;
|
||||||
system(qw(git-read-tree -u -m),
|
system(qw(git read-tree -u -m),
|
||||||
$tip_at_start, $tip_at_end);
|
$tip_at_start, $tip_at_end);
|
||||||
die "Fast-forward update failed: $?\n" if $?;
|
die "Fast-forward update failed: $?\n" if $?;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
system(qw(git-merge cvsimport HEAD), "$remote/$opt_o");
|
system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
|
||||||
die "Could not merge $opt_o into the current branch.\n" if $?;
|
die "Could not merge $opt_o into the current branch.\n" if $?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$orig_branch = "master";
|
$orig_branch = "master";
|
||||||
print "DONE; creating $orig_branch branch\n" if $opt_v;
|
print "DONE; creating $orig_branch branch\n" if $opt_v;
|
||||||
system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
|
system("git", "update-ref", "refs/heads/master", "$remote/$opt_o")
|
||||||
unless defined get_headref('refs/heads/master');
|
unless defined get_headref('refs/heads/master');
|
||||||
system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
|
system("git", "symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
|
||||||
if ($opt_r && $opt_o ne 'HEAD');
|
if ($opt_r && $opt_o ne 'HEAD');
|
||||||
system('git-update-ref', 'HEAD', "$orig_branch");
|
system('git', 'update-ref', 'HEAD', "$orig_branch");
|
||||||
unless ($opt_i) {
|
unless ($opt_i) {
|
||||||
system('git checkout -f');
|
system('git checkout -f');
|
||||||
die "checkout failed: $?\n" if $?;
|
die "checkout failed: $?\n" if $?;
|
||||||
|
Loading…
Reference in New Issue
Block a user