git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] transport-helper: add dont-update-private capability

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Aug 29, 2013, 18:58 UTC
Message-ID
<1377802704-30881-2-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<1377802704-30881-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>
---
Essentially the same as the patch I sent earlier, with doc and test.
 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..3085823 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.
 
+'dont-update-private'::
+	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
+	'dont-update-private'.
+
 
 Capabilities for Fetching
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/git-remote-testgit.sh b/git-remote-testgit.sh
index 2109070..a81aee8 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_DONT_UPDATE_PRIVATE" && echo "dont-update-private"
 		echo
 		;;
 	list)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 8c4c539..171cae3 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 dont-update-private' '
+	(cd local &&
+	echo more-update >>file &&
+	git commit -a -m more-update &&
+	git rev-parse --verify testgit/origin/heads/update >expect &&
+	GIT_REMOTE_TESTGIT_DONT_UPDATE_PRIVATE=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..639b0e3 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,
+		dont_update_private : 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, "dont-update-private")) {
+			data->dont_update_private = 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->dont_update_private)
 			continue;
 
 		/* propagate back the update to the remote namespace */
-- 
1.8.4.12.g98a4f55.dirty
Previous: Matthieu MoyNext: Felipe Contreras
Message 14 of 28 in “git-remote-mediawiki: reset private ref after non-dumb push”
  1. git-remote-mediawiki: reset private ref after non-dumb pushMatthieu Moy, Aug 13, 2013
  2. Felipe ContrerasAug 21, 2013
  3. Matthieu MoyAug 21, 2013
  4. Felipe ContrerasAug 22, 2013
  5. Matthieu MoyAug 23, 2013
  6. Felipe ContrerasAug 23, 2013
  7. Matthieu MoyAug 24, 2013
  8. Junio C HamanoAug 25, 2013
  9. Matthieu MoyAug 26, 2013
  10. Matthieu MoyAug 26, 2013
  11. Felipe ContrerasAug 26, 2013
  12. Matthieu MoyAug 27, 2013
  13. 1/4 git-remote-mediawiki: add test and check Makefile targetsMatthieu Moy, Aug 29, 2013
  14. 2/4 transport-helper: add dont-update-private capabilityMatthieu Moy, Aug 29, 2013
  15. Felipe ContrerasAug 29, 2013
  16. 1/4 git-remote-mediawiki: add test and check Makefile targetsMatthieu Moy, Sep 2, 2013
  17. 2/4 transport-helper: add no-private-update capabilityMatthieu Moy, Sep 2, 2013
  18. Felipe ContrerasSep 2, 2013
  19. 2/4 transport-helper: add dont-update-private capabilityMatthieu Moy, Sep 2, 2013
  20. 2/4 transport-helper: add no-private-update capabilityMatthieu Moy, Sep 3, 2013
  21. 3/4 git-remote-mediawiki: use no-private-update capability on dumb pushMatthieu Moy, Sep 2, 2013
  22. 4/4 git-remote-mediawiki: no need to update private ref in non-dumb pushMatthieu Moy, Sep 2, 2013
  23. 3/4 git-remote-mediawiki: use dont-update-private capability on dumb pushMatthieu Moy, Aug 29, 2013
  24. Junio C HamanoAug 29, 2013
  25. 4/4 git-remote-mediawiki: no need to update private ref in non-dumb pushMatthieu Moy, Aug 29, 2013
  26. Junio C HamanoAug 29, 2013
  27. Junio C HamanoAug 26, 2013
  28. Matthieu MoyAug 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.