All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH v2 2/4] transport-helper: add no-private-update capability
Date: Mon,  2 Sep 2013 09:19:46 +0200	[thread overview]
Message-ID: <1378106388-27992-2-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <1378106388-27992-1-git-send-email-Matthieu.Moy@imag.fr>

Since 664059fb62 (Felipe Contreras, Apr 17 2013, transport-helper: update
remote helper namespace), 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>
---
Change since v1: just changed the capability name.

 Documentation/gitremote-helpers.txt |  6 ++++++
 git-remote-testgit.sh               |  1 +
 t/t5801-remote-helpers.sh           | 11 +++++++++++
 transport-helper.c                  |  7 +++++--
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index 0827f69..1eacf1e 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -120,6 +120,12 @@ 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 2109070..6d2f282 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 8c4c539..613f69a 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 63cabc3..3328394 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 */
-- 
1.8.4.12.g98a4f55.dirty

  reply	other threads:[~2013-09-02  7:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13 13:31 [RFC/PATCH] git-remote-mediawiki: reset private ref after non-dumb push Matthieu Moy
2013-08-21 19:48 ` Felipe Contreras
2013-08-21 21:36   ` Matthieu Moy
2013-08-22 17:20     ` Felipe Contreras
2013-08-23  8:25       ` Matthieu Moy
2013-08-23 19:52         ` Felipe Contreras
2013-08-24  7:46           ` Matthieu Moy
2013-08-25  3:50             ` Junio C Hamano
2013-08-26  8:48               ` Matthieu Moy
2013-08-26  9:16                 ` Matthieu Moy
2013-08-26 16:28                   ` Felipe Contreras
2013-08-27  7:25                     ` Matthieu Moy
2013-08-29 18:58                       ` [PATCH 1/4] git-remote-mediawiki: add test and check Makefile targets Matthieu Moy
2013-08-29 18:58                         ` [PATCH 2/4] transport-helper: add dont-update-private capability Matthieu Moy
2013-08-29 19:14                           ` Felipe Contreras
2013-09-02  7:19                             ` [PATCH v2 1/4] git-remote-mediawiki: add test and check Makefile targets Matthieu Moy
2013-09-02  7:19                               ` Matthieu Moy [this message]
2013-09-02  7:28                                 ` [PATCH v2 2/4] transport-helper: add no-private-update capability Felipe Contreras
2013-09-02  7:41                                   ` [PATCH v3 2/4] transport-helper: add dont-update-private capability Matthieu Moy
2013-09-03 15:45                                     ` [PATCH v4 2/4] transport-helper: add no-private-update capability Matthieu Moy
2013-09-02  7:19                               ` [PATCH v2 3/4] git-remote-mediawiki: use no-private-update capability on dumb push Matthieu Moy
2013-09-02  7:19                               ` [PATCH v2 4/4] git-remote-mediawiki: no need to update private ref in non-dumb push Matthieu Moy
2013-08-29 18:58                         ` [PATCH 3/4] git-remote-mediawiki: use dont-update-private capability on dumb push Matthieu Moy
2013-08-29 19:08                           ` Junio C Hamano
2013-08-29 18:58                         ` [PATCH 4/4] git-remote-mediawiki: no need to update private ref in non-dumb push Matthieu Moy
2013-08-29 19:09                           ` Junio C Hamano
2013-08-26 16:26                 ` [RFC/PATCH] git-remote-mediawiki: reset private ref after " Junio C Hamano
2013-08-27  7:28                   ` Matthieu Moy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378106388-27992-2-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.