transport-helper: add no-private-update capability
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Tue, 3 Sep 2013 15:45:14 +0000 (17:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Sep 2013 18:57:53 +0000 (11:57 -0700)
Since 664059fb (transport-helper: update remote helper namespace,
2013-04-17), a 'push' operation on a remote helper updates the
private ref by default. This is often a good thing, but it can also
be desirable to disable this update to force the next 'pull' to
re-import the pushed revisions.

Allow remote-helpers to disable the automatic update by introducing a new
capability.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitremote-helpers.txt
git-remote-testgit.sh
t/t5801-remote-helpers.sh
transport-helper.c
index 0827f691396ba698d3976eba1eddedd9e7ff3e9e..ee9e134e949201f0fbcb342207b8951ef2f41052 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.
 
 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
 ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Capabilities for Fetching
 ^^^^^^^^^^^^^^^^^^^^^^^^^
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"
                        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)
                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 &&
 test_expect_success 'push update refs failure' '
        (cd local &&
        git checkout update &&
index 63cabc37e37dd338d3d9ee0764f099840d937600..3328394a9bb54d659747030729e2b5e86e7194a0 100644 (file)
@@ -27,7 +27,8 @@ struct helper_data {
                push : 1,
                connect : 1,
                signed_tags : 1,
                push : 1,
                connect : 1,
                signed_tags : 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 */
        char *export_marks;
        char *import_marks;
        /* These go from remote name (as in "list") to private name */
@@ -205,6 +206,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);
                        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.",
                } else if (mandatory) {
                        die("Unknown mandatory capability %s. This remote "
                            "helper probably needs newer version of Git.",
@@ -723,7 +726,7 @@ static void push_update_refs_status(struct helper_data *data,
                if (push_update_ref_status(&buf, &ref, remote_refs))
                        continue;
 
                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 */
                        continue;
 
                /* propagate back the update to the remote namespace */