git-remote-mediawiki: obey advice.pushNonFastForward
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthieu Moy committed
Sep 27, 2011 at 19:55 UTC
fd47d7b94dba1a6f3e38815d364200907ebd68f3
1 file changed
+10
-7
contrib/mw-to-git/git-remote-mediawiki
+10
-7
@@ -603,13 +603,16 @@ sub mw_import_ref {
603
}
604
605
sub error_non_fast_forward {
606
- # Native git-push would show this after the summary.
607
- # We can't ask it to display it cleanly, so print it
608
- # ourselves before.
609
- print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
610
- print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
611
- print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
612
-
606
+ my $advice = run_git("config --bool advice.pushNonFastForward");
607
+ chomp($advice);
608
+ if ($advice ne "false") {
609
+ # Native git-push would show this after the summary.
610
+ # We can't ask it to display it cleanly, so print it
611
+ # ourselves before.
612
+ print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
613
+ print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
614
+ print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
615
+ }
616
print STDOUT "error $_[0] \"non-fast-forward\"\n";
617
return 0;
618
}