+die "There is no .git dir in the current directory.\n" unless -d '.git';
+die "'a' must not exist in the current directory.\n" if -e 'a';
+die "'b' must not exist in the current directory.\n" if -e 'b';
+
+open(IN, '-|', 'git status') or die $!;
+my $status = join('', <IN>);
+close IN;
+die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
+die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
+
+my $lastversion;
+open(IN, '<', 'configure.in') or die $!;
+while (<IN>) {
+ if (/^RSYNC_VERSION=(.*)/) {
+ $lastversion = $1;
+ last;
+ }
+}
+close IN;
+
+open(IN, '<', 'OLDNEWS') or die $!;
+$_ = <IN>;
+close IN;
+my($lastrelease) = /(\d+\.\d+\.\d+)/;
+
+$lastversion = $lastrelease if $lastversion =~ /dev$/;
+my $version = $lastversion;
+$version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
+
+print "Please enter the version number of this release: [$version] ";
+chomp($_ = <STDIN>);
+if ($_ eq '.') {
+ $version =~ s/pre\d+//;
+} elsif ($_ ne '') {
+ $version = $_;
+}
+$lastversion = $lastrelease unless $version =~ s/[-.]*pre[-.]*/pre/;