Skip to content

Commit 100ce1c

Browse files
committed
Merge branch 'mm/mediawiki-dumb-push-fix'
* mm/mediawiki-dumb-push-fix: git-remote-mediawiki: no need to update private ref in non-dumb push git-remote-mediawiki: use no-private-update capability on dumb push transport-helper: add no-private-update capability git-remote-mediawiki: add test and check Makefile targets
2 parents af9a0ca + f19f5e6 commit 100ce1c

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
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
^^^^^^^^^^^^^^^^^^^^^^^^^

contrib/mw-to-git/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \
2424

2525
all: build
2626

27+
test: all
28+
$(MAKE) -C t
29+
30+
check: perlcritic test
31+
2732
install_pm:
2833
install $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
2934

@@ -41,4 +46,7 @@ clean:
4146
rm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
4247

4348
perlcritic:
44-
perlcritic -2 *.perl
49+
perlcritic -5 $(SCRIPT_PERL)
50+
-perlcritic -2 $(SCRIPT_PERL)
51+
52+
.PHONY: all test check install_pm install clean perlcritic

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ sub mw_capabilities {
590590
print {*STDOUT} "import\n";
591591
print {*STDOUT} "list\n";
592592
print {*STDOUT} "push\n";
593+
if ($dumb_push) {
594+
print {*STDOUT} "no-private-update\n";
595+
}
593596
print {*STDOUT} "\n";
594597
return;
595598
}
@@ -1211,7 +1214,6 @@ sub mw_push_revision {
12111214
}
12121215
if (!$dumb_push) {
12131216
run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
1214-
run_git(qq(update-ref -m "Git-MediaWiki push" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));
12151217
}
12161218
}
12171219

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
@@ -28,7 +28,8 @@ struct helper_data {
2828
connect : 1,
2929
signed_tags : 1,
3030
check_connectivity : 1,
31-
no_disconnect_req : 1;
31+
no_disconnect_req : 1,
32+
no_private_update : 1;
3233
char *export_marks;
3334
char *import_marks;
3435
/* These go from remote name (as in "list") to private name */
@@ -208,6 +209,8 @@ static struct child_process *get_helper(struct transport *transport)
208209
strbuf_addstr(&arg, "--import-marks=");
209210
strbuf_addstr(&arg, capname + strlen("import-marks "));
210211
data->import_marks = strbuf_detach(&arg, NULL);
212+
} else if (!prefixcmp(capname, "no-private-update")) {
213+
data->no_private_update = 1;
211214
} else if (mandatory) {
212215
die("Unknown mandatory capability %s. This remote "
213216
"helper probably needs newer version of Git.",
@@ -738,7 +741,7 @@ static void push_update_refs_status(struct helper_data *data,
738741
if (push_update_ref_status(&buf, &ref, remote_refs))
739742
continue;
740743

741-
if (!data->refspecs)
744+
if (!data->refspecs || data->no_private_update)
742745
continue;
743746

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

0 commit comments

Comments
 (0)