chiark / gitweb /
Dgit.pm: When checking that the tree is clean, check the git index too.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Feb 2018 18:49:17 +0000 (18:49 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 16 Feb 2018 10:08:14 +0000 (10:08 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
debian/changelog

index 7da60f664cb079438213fa95f70a7a899ab99d98..3657aa130acee7d88cfe8f0c17da2694acb8cc74 100644 (file)
@@ -445,14 +445,21 @@ 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;
+    foreach my $cached (qw(0 1)) {
+       my @cmd = qw(git diff --quiet);
+       push @cmd, qw(--cached) if $cached;
+       push @cmd, qw(HEAD);
+       debugcmd "+",@cmd;
+       $!=0; $?=-1; system @cmd;
+       return if !$?;
+       if ($?==256) {
+           fail
+               $cached
+               ? "git index contains changes (does not match HEAD)"
+               : "working tree is dirty (does not match HEAD)";
+       } else {
+           failedcmd @cmd;
+       }
     }
 }
 
index a37d22a1cfcf101bf04f6ac38f5b32abbf7cf5f4..964f063f92476730ed8133f0cca813ca17247417 100644 (file)
@@ -1,5 +1,8 @@
 dgit (4.4~) unstable; urgency=low
 
+  Bugfixes:
+  * When checking that the tree is clean, check the git index too.
+
   Minor fixes:
   * "confess" when we die due to a warning, rather than symply dieing.