1 # Do some git-status checking for the current dir and (optionally)
6 my($master_branch, $fatal_unless_clean, $check_patches_dir) = @_;
8 my($cur_branch) = check_git_status($fatal_unless_clean);
9 if ($cur_branch ne $master_branch) {
10 print "The checkout is not on the $master_branch branch.\n";
11 exit 1 if $master_branch ne 'master';
12 print "Do you want me to continue with --branch=$cur_branch? [n] ";
15 $_[0] = $master_branch = $cur_branch; # Updates caller's $master_branch too.
18 if ($check_patches_dir && -d 'patches/.git') {
19 ($cur_branch) = check_git_status($fatal_unless_clean, 'patches');
20 if ($cur_branch ne $master_branch) {
21 print "The *patches* checkout is on branch $cur_branch, not branch $master_branch.\n";
22 print "Do you want to change it to branch $master_branch? [n] ";
25 system "cd patches && git checkout '$master_branch'";
32 my($fatal_unless_clean, $subdir) = @_;
33 $subdir = '.' unless defined $subdir;
34 my $status = `cd '$subdir' && git status`;
35 my $is_clean = $status =~ /\nnothing to commit \(working directory clean\)/;
36 my($cur_branch) = $status =~ /^# On branch (.+)\n/;
37 if ($fatal_unless_clean && !$is_clean) {
41 $subdir = " *$subdir*";
43 die "The$subdir checkout is not clean:\n", $status;
45 ($cur_branch, $is_clean, $status);