+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;
+if ($lastversion =~ /dev$/) {
+ open(IN, '<', 'OLDNEWS') or die $!;
+ $_ = <IN>;
+ close IN;
+ ($lastversion) = /(\d+\.\d+\.\d+)/;
+}