my($fatal_unless_clean, $subdir) = @_;
$subdir = '.' unless defined $subdir;
my $status = `cd '$subdir' && git status`;
- my $is_clean = $status =~ /\nnothing to commit \(working directory clean\)/;
- my($cur_branch) = $status =~ /^# On branch (.+)\n/;
+ my $is_clean = $status =~ /\nnothing to commit.+working directory clean/;
+ my($cur_branch) = $status =~ /^(?:# )?On branch (.+)\n/;
if ($fatal_unless_clean && !$is_clean) {
if ($subdir eq '.') {
$subdir = '';
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 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/;
system "make $gen_target" and die "make $gen_target failed!\n";