Skip to content

Commit 21610d8

Browse files
felipecgitster
authored andcommitted
transport-helper: clarify pushing without refspecs
This has never worked, since it's inception the code simply skips all the refs, essentially telling fast-export to do nothing. Let's at least tell the user what's going on. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb0a5cc commit 21610d8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Documentation/gitremote-helpers.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ Miscellaneous capabilities
162162
For remote helpers that implement 'import' or 'export', this capability
163163
allows the refs to be constrained to a private namespace, instead of
164164
writing to refs/heads or refs/remotes directly.
165-
It is recommended that all importers providing the 'import' or 'export'
166-
capabilities use this.
165+
It is recommended that all importers providing the 'import'
166+
capability use this. It's mandatory for 'export'.
167167
+
168168
A helper advertising the capability
169169
`refspec refs/heads/*:refs/svn/origin/branches/*`

t/t5801-remote-helpers.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ test_expect_success 'pulling without refspecs' '
111111
compare_refs local2 HEAD server HEAD
112112
'
113113

114-
test_expect_failure 'pushing without refspecs' '
114+
test_expect_success 'pushing without refspecs' '
115115
test_when_finished "(cd local2 && git reset --hard origin)" &&
116116
(cd local2 &&
117117
echo content >>file &&
118118
git commit -a -m ten &&
119-
GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
120-
compare_refs local2 HEAD server HEAD
119+
GIT_REMOTE_TESTGIT_REFSPEC="" test_must_fail git push 2>../error) &&
120+
grep "remote-helper doesn.t support push; refspec needed" error
121121
'
122122

123123
test_expect_success 'pulling without marks' '

transport-helper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ static int push_refs_with_export(struct transport *transport,
785785
struct string_list revlist_args = STRING_LIST_INIT_NODUP;
786786
struct strbuf buf = STRBUF_INIT;
787787

788+
if (!data->refspecs)
789+
die("remote-helper doesn't support push; refspec needed");
790+
788791
helper = get_helper(transport);
789792

790793
write_constant(helper->in, "export\n");
@@ -795,8 +798,6 @@ static int push_refs_with_export(struct transport *transport,
795798
char *private;
796799
unsigned char sha1[20];
797800

798-
if (!data->refspecs)
799-
continue;
800801
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
801802
if (private && !get_sha1(private, sha1)) {
802803
strbuf_addf(&buf, "^%s", private);

0 commit comments

Comments
 (0)