chiark / gitweb /
dgit: Non-noop git fetch is not available with --dry-run, so fail
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 21 Jun 2018 00:00:41 +0000 (01:00 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 21 Jun 2018 00:11:11 +0000 (01:11 +0100)
When fetch or push wants git fetch (other than in a situation where it
happes to be a noop) but --dry-run was specified, we would loop with a
false coplaint about git fetch.  False, because we didn't actually run
git fetch so of course it didn't do anything.

Instead, fail with an explanation.  Closes:#871317.

This does not occur, and we do not fail, if git-fetch would be a
no-op.  We can tell when this is the case, because we use
git-ls-remote too.  This leads to one suggestion for a workaround for
the user, which is to do a not --dry-run fetch first.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index 3216e4aada2ecd61ce2ae4c29a22d1d7b44b8354..2c305561fcd6b7c9ab76191c8d435d352881b7e5 100644 (file)
@@ -10,6 +10,10 @@ dgit (5.2~) unstable; urgency=medium
     Closes:#883340.
   * When quilt fixup fails because of discrepancies, print a
     git diff rune which will show them.  Closes:#865446.
     Closes:#883340.
   * When quilt fixup fails because of discrepancies, print a
     git diff rune which will show them.  Closes:#865446.
+  * When fetch or push wants git fetch (other than in a situation where it
+    happes to be a noop) but --dry-run was specified, fail with an
+    explanation, rather than looping with a false coplaint about git
+    fetch.  Closes:#871317.
 
  --
 
 
  --
 
diff --git a/dgit b/dgit
index 961d974882fc568ef6b6061af805c0f2e99ab80f..3409e18df6a9d773fed86ee4ebcf32cc43720f8d 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2757,6 +2757,11 @@ END
            my $want = $wantr{$rrefname};
            next if $got eq $want;
            if (!defined $objgot{$want}) {
            my $want = $wantr{$rrefname};
            next if $got eq $want;
            if (!defined $objgot{$want}) {
+               fail <<END unless act_local();
+--dry-run specified but we actually wanted the results of git fetch,
+so this is not going to work.  Try running dgit fetch first,
+or using --damp-run instead of --dry-run.
+END
                print STDERR <<END;
 warning: git ls-remote suggests we want $lrefname
 warning:  and it should refer to $want
                print STDERR <<END;
 warning: git ls-remote suggests we want $lrefname
 warning:  and it should refer to $want