Merge branch 'mm/mediawiki-dumb-push-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2013 21:41:41 +0000 (14:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2013 21:41:41 +0000 (14:41 -0700)
* mm/mediawiki-dumb-push-fix:
git-remote-mediawiki: no need to update private ref in non-dumb push
git-remote-mediawiki: use no-private-update capability on dumb push
transport-helper: add no-private-update capability
git-remote-mediawiki: add test and check Makefile targets

Documentation/gitremote-helpers.txt
contrib/mw-to-git/Makefile
contrib/mw-to-git/git-remote-mediawiki.perl
git-remote-testgit.sh
t/t5801-remote-helpers.sh
transport-helper.c
index bc069c23df85ae200d8b21fdf9a4662c72152377..be7e224a03c4c5079342c3bbb23b39ad38ca9a5c 100644 (file)
@@ -120,6 +120,11 @@ connecting (see the 'connect' command under COMMANDS).
 When choosing between 'push' and 'export', Git prefers 'push'.
 Other frontends may have some other order of preference.
 
+'no-private-update'::
+       When using the 'refspec' capability, git normally updates the
+       private ref on successful push. This update is disabled when
+       the remote-helper declares the capability 'no-private-update'.
+
 
 Capabilities for Fetching
 ^^^^^^^^^^^^^^^^^^^^^^^^^
index 76fcd4defcc3ac751aa0c85b6388f6d408b476ca..f206f9655b4c078c66cb885fd079c4a7b95f7949 100644 (file)
@@ -24,6 +24,11 @@ INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \
 
 all: build
 
+test: all
+       $(MAKE) -C t
+
+check: perlcritic test
+
 install_pm:
        install $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
 
@@ -41,4 +46,7 @@ clean:
        rm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
 
 perlcritic:
-       perlcritic -2 *.perl
+       perlcritic -5 $(SCRIPT_PERL)
+       -perlcritic -2 $(SCRIPT_PERL)
+
+.PHONY: all test check install_pm install clean perlcritic
index f8d7d2ca6c0926912200ddcadf8359c1b9bfef44..c9a4805ec1f0d5767af7a5f27428db5a02fa94a1 100755 (executable)
@@ -590,6 +590,9 @@ sub mw_capabilities {
        print {*STDOUT} "import\n";
        print {*STDOUT} "list\n";
        print {*STDOUT} "push\n";
+       if ($dumb_push) {
+               print {*STDOUT} "no-private-update\n";
+       }
        print {*STDOUT} "\n";
        return;
 }
@@ -1211,7 +1214,6 @@ sub mw_push_revision {
                }
                if (!$dumb_push) {
                        run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
-                       run_git(qq(update-ref -m "Git-MediaWiki push" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));
                }
        }
 
index 2109070d00411dbd9f1ba70e55587091d50a8a08..6d2f282d32212b605a1237bae224ecbba05cacd1 100755 (executable)
@@ -38,6 +38,7 @@ do
                        echo "*export-marks $gitmarks"
                fi
                test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
+               test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
                echo
                ;;
        list)
index 8c4c5396a8447fc39d6f0c697af761631b08b3f7..613f69a254bab23e1f09126b4a7f3dca8692deaa 100755 (executable)
@@ -182,6 +182,17 @@ test_expect_success 'push update refs' '
        )
 '
 
+test_expect_success 'push update refs disabled by no-private-update' '
+       (cd local &&
+       echo more-update >>file &&
+       git commit -a -m more-update &&
+       git rev-parse --verify testgit/origin/heads/update >expect &&
+       GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE=t git push origin update &&
+       git rev-parse --verify testgit/origin/heads/update >actual &&
+       test_cmp expect actual
+       )
+'
+
 test_expect_success 'push update refs failure' '
        (cd local &&
        git checkout update &&
index 4c2a39e8ff03df5285657a5c0f9b7746c28d76a6..b32e2d64dd344c3f8c4d5f42b6c48dd6bdb8d29f 100644 (file)
@@ -28,7 +28,8 @@ struct helper_data {
                connect : 1,
                signed_tags : 1,
                check_connectivity : 1,
-               no_disconnect_req : 1;
+               no_disconnect_req : 1,
+               no_private_update : 1;
        char *export_marks;
        char *import_marks;
        /* These go from remote name (as in "list") to private name */
@@ -208,6 +209,8 @@ static struct child_process *get_helper(struct transport *transport)
                        strbuf_addstr(&arg, "--import-marks=");
                        strbuf_addstr(&arg, capname + strlen("import-marks "));
                        data->import_marks = strbuf_detach(&arg, NULL);
+               } else if (!prefixcmp(capname, "no-private-update")) {
+                       data->no_private_update = 1;
                } else if (mandatory) {
                        die("Unknown mandatory capability %s. This remote "
                            "helper probably needs newer version of Git.",
@@ -738,7 +741,7 @@ static void push_update_refs_status(struct helper_data *data,
                if (push_update_ref_status(&buf, &ref, remote_refs))
                        continue;
 
-               if (!data->refspecs)
+               if (!data->refspecs || data->no_private_update)
                        continue;
 
                /* propagate back the update to the remote namespace */