summaryrefslogtreecommitdiff
path: root/git-cvsexportcommit.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-06-13 19:47:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-06-13 19:47:47 (GMT)
commit49c7e4643b27ff07463b1a8774fee25ef22a0d1c (patch)
tree92d17857dc2f6057cfcf237c0c12be30539863d8 /git-cvsexportcommit.perl
parent1bbc820414d94452d1417bb83db86309f34720a3 (diff)
parent54d5cc0e126ed4b6cc4b186efd9faf7b93df570f (diff)
downloadgit-49c7e4643b27ff07463b1a8774fee25ef22a0d1c.zip
git-49c7e4643b27ff07463b1a8774fee25ef22a0d1c.tar.gz
git-49c7e4643b27ff07463b1a8774fee25ef22a0d1c.tar.bz2
Merge branch 'nw/maint-cvsexportcommit'
* nw/maint-cvsexportcommit: git-cvsexportcommit can't commit files which have been removed from CVS
Diffstat (limited to 'git-cvsexportcommit.perl')
-rwxr-xr-xgit-cvsexportcommit.perl49
1 files changed, 35 insertions, 14 deletions
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 6d9f0ef..9ec1df9 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -225,7 +225,14 @@ if (@canstatusfiles) {
foreach my $name (keys %todo) {
my $basename = basename($name);
- $basename = "no file " . $basename if (exists($added{$basename}));
+ # CVS reports files that don't exist in the current revision as
+ # "no file $basename" in its "status" output, so we should
+ # anticipate that. Totally unknown files will have a status
+ # "Unknown". However, if they exist in the Attic, their status
+ # will be "Up-to-date" (this means they were added once but have
+ # been removed).
+ $basename = "no file $basename" if $added{$basename};
+
$basename =~ s/^\s+//;
$basename =~ s/\s+$//;
@@ -233,31 +240,45 @@ if (@canstatusfiles) {
$fullname{$basename} = $name;
push (@canstatusfiles2, $name);
delete($todo{$name});
- }
+ }
}
my @cvsoutput;
@cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles2);
foreach my $l (@cvsoutput) {
- chomp $l;
- if ($l =~ /^File:\s+(.*\S)\s+Status: (.*)$/) {
- if (!exists($fullname{$1})) {
- print STDERR "Huh? Status reported for unexpected file '$1'\n";
- } else {
- $cvsstat{$fullname{$1}} = $2;
- }
- }
+ chomp $l;
+ next unless
+ my ($file, $status) = $l =~ /^File:\s+(.*\S)\s+Status: (.*)$/;
+
+ my $fullname = $fullname{$file};
+ print STDERR "Huh? Status '$status' reported for unexpected file '$file'\n"
+ unless defined $fullname;
+
+ # This response means the file does not exist except in
+ # CVS's attic, so set the status accordingly
+ $status = "In-attic"
+ if $file =~ /^no file /
+ && $status eq 'Up-to-date';
+
+ $cvsstat{$fullname{$file}} = $status;
}
}
}
-# ... validate new files,
+# ... Validate that new files have the correct status
foreach my $f (@afiles) {
- if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") {
- $dirty = 1;
+ next unless defined(my $stat = $cvsstat{$f});
+
+ # This means the file has never been seen before
+ next if $stat eq 'Unknown';
+
+ # This means the file has been seen before but was removed
+ next if $stat eq 'In-attic';
+
+ $dirty = 1;
warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
warn "Status was: $cvsstat{$f}\n";
- }
}
+
# ... validate known files.
foreach my $f (@files) {
next if grep { $_ eq $f } @afiles;