X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-cvsexportcommit.perl;h=f284c88a46b5cc7d6e75b78346829ce03e60b060;hb=6e863d6d129a1b6a13c66d0bb03f3d43db6c51fe;hp=42060ef6e165b6b39e4842138013cf264688ebd5;hpb=bd724be4bec4e75014e8e528a9c3c9a90b2d4488;p=git.git diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index 42060ef6e..f284c88a4 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -30,11 +30,6 @@ if ($opt_d) { @cvs = ('cvs'); } -# setup a tempdir -our ($tmpdir, $tmpdirname) = tempdir('git-cvsapplycommit-XXXXXX', - TMPDIR => 1, - CLEANUP => 1); - # resolve target commit my $commit; $commit = pop @ARGV; @@ -134,7 +129,7 @@ my $context = $opt_p ? '' : '-C1'; print "Checking if patch will apply\n"; my @stat; -open APPLY, "GIT_DIR= git-apply $context --binary --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; +open APPLY, "GIT_DIR= git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; @stat=; close APPLY || die "Cannot patch"; my (@bfiles,@files,@afiles,@dfiles); @@ -197,7 +192,7 @@ if (@canstatusfiles) { # ... validate new files, foreach my $f (@afiles) { if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") { - $dirty = 1; + $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"; } @@ -220,10 +215,21 @@ if ($dirty) { } print "Applying\n"; -`GIT_DIR= git-apply $context --binary --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; +`GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; print "Patch applied successfully. Adding new files and directories to CVS\n"; my $dirtypatch = 0; + +# +# We have to add the directories in order otherwise we will have +# problems when we try and add the sub-directory of a directory we +# have not added yet. +# +# Luckily this is easy to deal with by sorting the directories and +# dealing with the shortest ones first. +# +@dirs = sort { length $a <=> length $b} @dirs; + foreach my $d (@dirs) { if (system(@cvs,'add',$d)) { $dirtypatch = 1; @@ -281,6 +287,11 @@ if ($opt_c) { # clean up unlink(".cvsexportcommit.diff"); +# CVS version 1.11.x and 1.12.x sleeps the wrong way to ensure the timestamp +# used by CVS and the one set by subsequence file modifications are different. +# If they are not different CVS will not detect changes. +sleep(1); + sub usage { print STDERR <