svn import: Do not create empty tags
If a tag is "clean", do not create a commit for it. Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>
This commit is contained in:
parent
f02b3eba7f
commit
bf267d99e8
@ -407,141 +407,146 @@ sub commit {
|
|||||||
$last_rev = $rev;
|
$last_rev = $rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(my($path,$action) = each %$changed_paths) {
|
my $cid;
|
||||||
if ($action->[0] eq "A") {
|
if($tag and not %$changed_paths) {
|
||||||
my $f = get_file($revision,$branch,$path);
|
$cid = $rev;
|
||||||
push(@new,$f) if $f;
|
} else {
|
||||||
} elsif ($action->[0] eq "D") {
|
while(my($path,$action) = each %$changed_paths) {
|
||||||
push(@old,$path);
|
if ($action->[0] eq "A") {
|
||||||
} elsif ($action->[0] eq "M") {
|
my $f = get_file($revision,$branch,$path);
|
||||||
my $f = get_file($revision,$branch,$path);
|
push(@new,$f) if $f;
|
||||||
push(@new,$f) if $f;
|
} elsif ($action->[0] eq "D") {
|
||||||
} elsif ($action->[0] eq "R") {
|
push(@old,$path);
|
||||||
# refer to a file/tree in an earlier commit
|
} elsif ($action->[0] eq "M") {
|
||||||
push(@old,$path); # remove any old stuff
|
my $f = get_file($revision,$branch,$path);
|
||||||
|
push(@new,$f) if $f;
|
||||||
|
} elsif ($action->[0] eq "R") {
|
||||||
|
# refer to a file/tree in an earlier commit
|
||||||
|
push(@old,$path); # remove any old stuff
|
||||||
|
|
||||||
# ... and add any new stuff
|
# ... and add any new stuff
|
||||||
my($b,$p) = split_path($revision,$action->[1]);
|
my($b,$p) = split_path($revision,$action->[1]);
|
||||||
open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->[2]}, $p;
|
open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->[2]}, $p;
|
||||||
|
local $/ = '\0';
|
||||||
|
while(<$F>) {
|
||||||
|
chomp;
|
||||||
|
my($m,$p) = split(/\t/,$_,2);
|
||||||
|
my($mode,$type,$sha1) = split(/ /,$m);
|
||||||
|
next if $type ne "blob";
|
||||||
|
push(@new,[$mode,$sha1,$p]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die "$revision: unknown action '".$action->[0]."' for $path\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(@old) {
|
||||||
|
open my $F, "-|", "git-ls-files", "-z", @old or die $!;
|
||||||
|
@old = ();
|
||||||
local $/ = '\0';
|
local $/ = '\0';
|
||||||
while(<$F>) {
|
while(<$F>) {
|
||||||
chomp;
|
chomp;
|
||||||
my($m,$p) = split(/\t/,$_,2);
|
push(@old,$_);
|
||||||
my($mode,$type,$sha1) = split(/ /,$m);
|
|
||||||
next if $type ne "blob";
|
|
||||||
push(@new,[$mode,$sha1,$p]);
|
|
||||||
}
|
}
|
||||||
} else {
|
close($F);
|
||||||
die "$revision: unknown action '".$action->[0]."' for $path\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(@old) {
|
while(@old) {
|
||||||
open my $F, "-|", "git-ls-files", "-z", @old or die $!;
|
my @o2;
|
||||||
@old = ();
|
if(@old > 55) {
|
||||||
local $/ = '\0';
|
@o2 = splice(@old,0,50);
|
||||||
while(<$F>) {
|
} else {
|
||||||
chomp;
|
@o2 = @old;
|
||||||
push(@old,$_);
|
@old = ();
|
||||||
|
}
|
||||||
|
system("git-update-index","--force-remove","--",@o2);
|
||||||
|
die "Cannot remove files: $?\n" if $?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close($F);
|
while(@new) {
|
||||||
|
my @n2;
|
||||||
while(@old) {
|
if(@new > 12) {
|
||||||
my @o2;
|
@n2 = splice(@new,0,10);
|
||||||
if(@old > 55) {
|
|
||||||
@o2 = splice(@old,0,50);
|
|
||||||
} else {
|
} else {
|
||||||
@o2 = @old;
|
@n2 = @new;
|
||||||
@old = ();
|
@new = ();
|
||||||
}
|
}
|
||||||
system("git-update-index","--force-remove","--",@o2);
|
system("git-update-index","--add",
|
||||||
die "Cannot remove files: $?\n" if $?;
|
(map { ('--cacheinfo', @$_) } @n2));
|
||||||
|
die "Cannot add files: $?\n" if $?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
while(@new) {
|
my $pid = open(C,"-|");
|
||||||
my @n2;
|
die "Cannot fork: $!" unless defined $pid;
|
||||||
if(@new > 12) {
|
unless($pid) {
|
||||||
@n2 = splice(@new,0,10);
|
exec("git-write-tree");
|
||||||
} else {
|
die "Cannot exec git-write-tree: $!\n";
|
||||||
@n2 = @new;
|
|
||||||
@new = ();
|
|
||||||
}
|
}
|
||||||
system("git-update-index","--add",
|
chomp(my $tree = <C>);
|
||||||
(map { ('--cacheinfo', @$_) } @n2));
|
length($tree) == 40
|
||||||
die "Cannot add files: $?\n" if $?;
|
or die "Cannot get tree id ($tree): $!\n";
|
||||||
}
|
close(C)
|
||||||
|
or die "Error running git-write-tree: $?\n";
|
||||||
|
print "Tree ID $tree\n" if $opt_v;
|
||||||
|
|
||||||
my $pid = open(C,"-|");
|
my $pr = IO::Pipe->new() or die "Cannot open pipe: $!\n";
|
||||||
die "Cannot fork: $!" unless defined $pid;
|
my $pw = IO::Pipe->new() or die "Cannot open pipe: $!\n";
|
||||||
unless($pid) {
|
$pid = fork();
|
||||||
exec("git-write-tree");
|
die "Fork: $!\n" unless defined $pid;
|
||||||
die "Cannot exec git-write-tree: $!\n";
|
unless($pid) {
|
||||||
}
|
$pr->writer();
|
||||||
chomp(my $tree = <C>);
|
$pw->reader();
|
||||||
length($tree) == 40
|
open(OUT,">&STDOUT");
|
||||||
or die "Cannot get tree id ($tree): $!\n";
|
dup2($pw->fileno(),0);
|
||||||
close(C)
|
dup2($pr->fileno(),1);
|
||||||
or die "Error running git-write-tree: $?\n";
|
$pr->close();
|
||||||
print "Tree ID $tree\n" if $opt_v;
|
$pw->close();
|
||||||
|
|
||||||
my $pr = IO::Pipe->new() or die "Cannot open pipe: $!\n";
|
my @par = ();
|
||||||
my $pw = IO::Pipe->new() or die "Cannot open pipe: $!\n";
|
@par = ("-p",$rev) if defined $rev;
|
||||||
$pid = fork();
|
|
||||||
die "Fork: $!\n" unless defined $pid;
|
# loose detection of merges
|
||||||
unless($pid) {
|
# based on the commit msg
|
||||||
$pr->writer();
|
foreach my $rx (@mergerx) {
|
||||||
$pw->reader();
|
if ($message =~ $rx) {
|
||||||
open(OUT,">&STDOUT");
|
my $mparent = $1;
|
||||||
dup2($pw->fileno(),0);
|
if ($mparent eq 'HEAD') { $mparent = $opt_o };
|
||||||
dup2($pr->fileno(),1);
|
if ( -e "$git_dir/refs/heads/$mparent") {
|
||||||
$pr->close();
|
$mparent = get_headref($mparent, $git_dir);
|
||||||
|
push @par, '-p', $mparent;
|
||||||
|
print OUT "Merge parent branch: $mparent\n" if $opt_v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exec("env",
|
||||||
|
"GIT_AUTHOR_NAME=$author_name",
|
||||||
|
"GIT_AUTHOR_EMAIL=$author_email",
|
||||||
|
"GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
|
||||||
|
"GIT_COMMITTER_NAME=$author_name",
|
||||||
|
"GIT_COMMITTER_EMAIL=$author_email",
|
||||||
|
"GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
|
||||||
|
"git-commit-tree", $tree,@par);
|
||||||
|
die "Cannot exec git-commit-tree: $!\n";
|
||||||
|
}
|
||||||
|
$pw->writer();
|
||||||
|
$pr->reader();
|
||||||
|
|
||||||
|
$message =~ s/[\s\n]+\z//;
|
||||||
|
|
||||||
|
print $pw "$message\n"
|
||||||
|
or die "Error writing to git-commit-tree: $!\n";
|
||||||
$pw->close();
|
$pw->close();
|
||||||
|
|
||||||
my @par = ();
|
print "Committed change $revision:$branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v;
|
||||||
@par = ("-p",$rev) if defined $rev;
|
chomp($cid = <$pr>);
|
||||||
|
length($cid) == 40
|
||||||
|
or die "Cannot get commit id ($cid): $!\n";
|
||||||
|
print "Commit ID $cid\n" if $opt_v;
|
||||||
|
$pr->close();
|
||||||
|
|
||||||
# loose detection of merges
|
waitpid($pid,0);
|
||||||
# based on the commit msg
|
die "Error running git-commit-tree: $?\n" if $?;
|
||||||
foreach my $rx (@mergerx) {
|
|
||||||
if ($message =~ $rx) {
|
|
||||||
my $mparent = $1;
|
|
||||||
if ($mparent eq 'HEAD') { $mparent = $opt_o };
|
|
||||||
if ( -e "$git_dir/refs/heads/$mparent") {
|
|
||||||
$mparent = get_headref($mparent, $git_dir);
|
|
||||||
push @par, '-p', $mparent;
|
|
||||||
print OUT "Merge parent branch: $mparent\n" if $opt_v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exec("env",
|
|
||||||
"GIT_AUTHOR_NAME=$author_name",
|
|
||||||
"GIT_AUTHOR_EMAIL=$author_email",
|
|
||||||
"GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
|
|
||||||
"GIT_COMMITTER_NAME=$author_name",
|
|
||||||
"GIT_COMMITTER_EMAIL=$author_email",
|
|
||||||
"GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
|
|
||||||
"git-commit-tree", $tree,@par);
|
|
||||||
die "Cannot exec git-commit-tree: $!\n";
|
|
||||||
}
|
}
|
||||||
$pw->writer();
|
|
||||||
$pr->reader();
|
|
||||||
|
|
||||||
$message =~ s/[\s\n]+\z//;
|
|
||||||
|
|
||||||
print $pw "$message\n"
|
|
||||||
or die "Error writing to git-commit-tree: $!\n";
|
|
||||||
$pw->close();
|
|
||||||
|
|
||||||
print "Committed change $revision:$branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v;
|
|
||||||
chomp(my $cid = <$pr>);
|
|
||||||
length($cid) == 40
|
|
||||||
or die "Cannot get commit id ($cid): $!\n";
|
|
||||||
print "Commit ID $cid\n" if $opt_v;
|
|
||||||
$pr->close();
|
|
||||||
|
|
||||||
waitpid($pid,0);
|
|
||||||
die "Error running git-commit-tree: $?\n" if $?;
|
|
||||||
|
|
||||||
if(not defined $dest) {
|
if(not defined $dest) {
|
||||||
print "... no known parent\n" if $opt_v;
|
print "... no known parent\n" if $opt_v;
|
||||||
|
Loading…
Reference in New Issue
Block a user