Skip to content

Commit 597b831

Browse files
moygitster
authored andcommitted
transport-helper: add no-private-update capability
Since 664059f (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8987cda commit 597b831

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Documentation/gitremote-helpers.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ connecting (see the 'connect' command under COMMANDS).
120120
When choosing between 'push' and 'export', Git prefers 'push'.
121121
Other frontends may have some other order of preference.
122122

123+
'no-private-update'::
124+
When using the 'refspec' capability, git normally updates the
125+
private ref on successful push. This update is disabled when
126+
the remote-helper declares the capability 'no-private-update'.
127+
123128

124129
Capabilities for Fetching
125130
^^^^^^^^^^^^^^^^^^^^^^^^^

git-remote-testgit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ do
3838
echo "*export-marks $gitmarks"
3939
fi
4040
test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
41+
test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
4142
echo
4243
;;
4344
list)

t/t5801-remote-helpers.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ test_expect_success 'push update refs' '
182182
)
183183
'
184184

185+
test_expect_success 'push update refs disabled by no-private-update' '
186+
(cd local &&
187+
echo more-update >>file &&
188+
git commit -a -m more-update &&
189+
git rev-parse --verify testgit/origin/heads/update >expect &&
190+
GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE=t git push origin update &&
191+
git rev-parse --verify testgit/origin/heads/update >actual &&
192+
test_cmp expect actual
193+
)
194+
'
195+
185196
test_expect_success 'push update refs failure' '
186197
(cd local &&
187198
git checkout update &&

transport-helper.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ struct helper_data {
2727
push : 1,
2828
connect : 1,
2929
signed_tags : 1,
30-
no_disconnect_req : 1;
30+
no_disconnect_req : 1,
31+
no_private_update : 1;
3132
char *export_marks;
3233
char *import_marks;
3334
/* These go from remote name (as in "list") to private name */
@@ -205,6 +206,8 @@ static struct child_process *get_helper(struct transport *transport)
205206
strbuf_addstr(&arg, "--import-marks=");
206207
strbuf_addstr(&arg, capname + strlen("import-marks "));
207208
data->import_marks = strbuf_detach(&arg, NULL);
209+
} else if (!prefixcmp(capname, "no-private-update")) {
210+
data->no_private_update = 1;
208211
} else if (mandatory) {
209212
die("Unknown mandatory capability %s. This remote "
210213
"helper probably needs newer version of Git.",
@@ -723,7 +726,7 @@ static void push_update_refs_status(struct helper_data *data,
723726
if (push_update_ref_status(&buf, &ref, remote_refs))
724727
continue;
725728

726-
if (!data->refspecs)
729+
if (!data->refspecs || data->no_private_update)
727730
continue;
728731

729732
/* propagate back the update to the remote namespace */

0 commit comments

Comments
 (0)