Merge branch 'maint-1.7.7' into maint
[gitweb.git] / contrib / mw-to-git / git-remote-mediawiki
index 9bb58ab65f4389ae36cf9ac28bdf9970c269c316..c18bfa1f1515a8edb27c2d468a2982860a561939 100755 (executable)
@@ -76,8 +76,10 @@ my $wiki_login = run_git("config --get remote.". $remotename .".mwLogin");
 # inside a remote helper, so our stdin is connect to git, not to a
 # terminal.
 my $wiki_passwd = run_git("config --get remote.". $remotename .".mwPassword");
+my $wiki_domain = run_git("config --get remote.". $remotename .".mwDomain");
 chomp($wiki_login);
 chomp($wiki_passwd);
+chomp($wiki_domain);
 
 # Import only last revisions (both for clone and fetch)
 my $shallow_import = run_git("config --get --bool remote.". $remotename .".shallow");
@@ -107,6 +109,10 @@ $dumb_push = ($dumb_push eq "true");
 
 my $wiki_name = $url;
 $wiki_name =~ s/[^\/]*:\/\///;
+# If URL is like http://user:password@example.com/, we clearly don't
+# want the password in $wiki_name. While we're there, also remove user
+# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
+$wiki_name =~ s/^.*@//;
 
 # Commands parser
 my $entry;
@@ -158,6 +164,7 @@ sub mw_connect_maybe {
                if (!$mediawiki->login({
                        lgname => $wiki_login,
                        lgpassword => $wiki_passwd,
+                       lgdomain => $wiki_domain,
                })) {
                        print STDERR "Failed to log in mediawiki user \"$wiki_login\" on $url\n";
                        print STDERR "(error " .
@@ -603,13 +610,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;
 }