diff options
author | Matthieu Moy <Matthieu.Moy@imag.fr> | 2013-09-03 17:45:14 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-03 11:57:53 -0700 |
commit | 597b831afb25303218ac60115ac86dd8879e3ce3 (patch) | |
tree | b10ad6d0a1c2c9a3dda65a7c75b0c10a6cc239e5 | |
parent | 8987cda9e1e1c36e5d0a9be6d371697e50773856 (diff) | |
download | git-597b831afb25303218ac60115ac86dd8879e3ce3.tar.gz |
transport-helper: add no-private-update capability
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>
-rw-r--r-- | Documentation/gitremote-helpers.txt | 5 | ||||
-rwxr-xr-x | git-remote-testgit.sh | 1 | ||||
-rwxr-xr-x | t/t5801-remote-helpers.sh | 11 | ||||
-rw-r--r-- | transport-helper.c | 7 |
4 files changed, 22 insertions, 2 deletions
diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt index 0827f69139..ee9e134e94 100644 --- a/Documentation/gitremote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/git-remote-testgit.sh b/git-remote-testgit.sh index 2109070d00..6d2f282d32 100755 --- a/git-remote-testgit.sh +++ b/git-remote-testgit.sh @@ -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) diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 8c4c5396a8..613f69a254 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -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 && diff --git a/transport-helper.c b/transport-helper.c index 63cabc37e3..3328394a9b 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -27,7 +27,8 @@ struct helper_data { 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 */ @@ -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); + } 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.", @@ -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 (!data->refspecs) + if (!data->refspecs || data->no_private_update) continue; /* propagate back the update to the remote namespace */ |