chiark / gitweb /
dgit: Break out clean_tre_check_git
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 7eb05312d3114d3a97aec5705256c91e5d4a1518..de697a15a22a1c1aeb5b84ef23e931baf30023a4 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -6203,20 +6203,25 @@ sub maybe_unapply_patches_again () {
 
 #----- other building -----
 
+sub clean_tree_check_git ($$) {
+    my ($honour_ignores, $message) = @_;
+    my @cmd = (@git, qw(clean -dn));
+    push @cmd, qw(-x) unless $honour_ignores;
+    my $leftovers = cmdoutput @cmd;
+    if (length $leftovers) {
+       print STDERR $leftovers, "\n" or confess $!;
+       fail $message;
+    }
+}
+
 sub clean_tree_check () {
     # Not yet fully implemented.
     # This function needs to not care about modified but tracked files.
     # That was done by check_not_dirty, and by now we may have run
     # the rules clean target which might modify tracked files (!)
     if ($cleanmode =~ m{^check}) {
-       my @cmd = (@git, qw(clean -dn));
-       push @cmd, qw(-x) unless $cleanmode =~ m{ignores};
-       my $leftovers = cmdoutput @cmd;
-       if (length $leftovers) {
-           print STDERR $leftovers, "\n" or confess $!;
-           fail __
+       clean_tree_check_git +($cleanmode =~ m{ignores}), __
  "tree contains uncommitted files and --clean=check specified";
-       }
     }
 }