chiark / gitweb /
Dgit.pm: break out git_check_unmodified from dgit
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Feb 2018 18:45:17 +0000 (18:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 11:25:49 +0000 (12:25 +0100)
We (have to) use just "git" rather than @git, but this is OK I think.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
dgit

index a4ec377..7da60f6 100644 (file)
@@ -51,6 +51,7 @@ BEGIN {
                       git_rev_parse git_cat_file
                      git_get_ref git_get_symref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
+                     git_check_unmodified
                       $package_re $component_re $deliberately_re
                      $distro_re $versiontag_re $series_filename_re
                      $extra_orig_namepart_re
@@ -443,6 +444,18 @@ sub git_for_each_tag_referring ($$) {
     });
 }
 
+sub git_check_unmodified () {
+    my @cmd = qw(git diff --quiet HEAD);
+    debugcmd "+",@cmd;
+    $!=0; $?=-1; system @cmd;
+    return if !$?;
+    if ($?==256) {
+       fail "working tree is dirty (does not match HEAD)";
+    } else {
+       failedcmd @cmd;
+    }
+}
+
 sub is_fast_fwd ($$) {
     my ($ancestor,$child) = @_;
     my @cmd = (qw(git merge-base), $ancestor, $child);
diff --git a/dgit b/dgit
index 573f39a..17e4fad 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -3692,15 +3692,7 @@ sub check_not_dirty () {
 
     return if $ignoredirty;
 
-    my @cmd = (@git, qw(diff --quiet HEAD));
-    debugcmd "+",@cmd;
-    $!=0; $?=-1; system @cmd;
-    return if !$?;
-    if ($?==256) {
-       fail "working tree is dirty (does not match HEAD)";
-    } else {
-       failedcmd @cmd;
-    }
+    git_check_unmodified();
 }
 
 sub commit_admin ($) {