Code

git-remote-mediawiki: obey advice.pushNonFastForward
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Tue, 27 Sep 2011 17:55:00 +0000 (19:55 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Sep 2011 18:25:03 +0000 (11:25 -0700)
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/mw-to-git/git-remote-mediawiki

index 9bb58ab65f4389ae36cf9ac28bdf9970c269c316..b809792853c0e9623f56273f0e6c97207887f21a 100755 (executable)
@@ -603,13 +603,16 @@ sub mw_import_ref {
 }
 
 sub error_non_fast_forward {
-       # Native git-push would show this after the summary.
-       # We can't ask it to display it cleanly, so print it
-       # ourselves before.
-       print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
-       print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
-       print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
-
+       my $advice = run_git("config --bool advice.pushNonFastForward");
+       chomp($advice);
+       if ($advice ne "false") {
+               # Native git-push would show this after the summary.
+               # We can't ask it to display it cleanly, so print it
+               # ourselves before.
+               print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
+               print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
+               print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
+       }
        print STDOUT "error $_[0] \"non-fast-forward\"\n";
        return 0;
 }