Skip to content

Commit f582dc3

Browse files
committed
Merge branch 'jc/disable-push-nego-for-deletion'
"git push" that pushes only deletion gave an unnecessary and harmless error message when push negotiation is configured, which has been corrected. * jc/disable-push-nego-for-deletion: push: avoid showing false negotiation errors
2 parents fbeed64 + 4d8ee03 commit f582dc3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

send-pack.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,17 +427,26 @@ static void get_commons_through_negotiation(const char *url,
427427
struct child_process child = CHILD_PROCESS_INIT;
428428
const struct ref *ref;
429429
int len = the_hash_algo->hexsz + 1; /* hash + NL */
430+
int nr_negotiation_tip = 0;
430431

431432
child.git_cmd = 1;
432433
child.no_stdin = 1;
433434
child.out = -1;
434435
strvec_pushl(&child.args, "fetch", "--negotiate-only", NULL);
435436
for (ref = remote_refs; ref; ref = ref->next) {
436-
if (!is_null_oid(&ref->new_oid))
437-
strvec_pushf(&child.args, "--negotiation-tip=%s", oid_to_hex(&ref->new_oid));
437+
if (!is_null_oid(&ref->new_oid)) {
438+
strvec_pushf(&child.args, "--negotiation-tip=%s",
439+
oid_to_hex(&ref->new_oid));
440+
nr_negotiation_tip++;
441+
}
438442
}
439443
strvec_push(&child.args, url);
440444

445+
if (!nr_negotiation_tip) {
446+
child_process_clear(&child);
447+
return;
448+
}
449+
441450
if (start_command(&child))
442451
die(_("send-pack: unable to fork off fetch subprocess"));
443452

t/t5516-fetch-push.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ test_expect_success 'push with negotiation proceeds anyway even if negotiation f
230230
test_grep "push negotiation failed" err
231231
'
232232

233+
test_expect_success 'push deletion with negotiation' '
234+
mk_empty testrepo &&
235+
git push testrepo $the_first_commit:refs/heads/master &&
236+
git -c push.negotiate=1 push testrepo \
237+
:master $the_first_commit:refs/heads/next 2>errors-2 &&
238+
test_grep ! "negotiate-only needs one or " errors-2 &&
239+
git -c push.negotiate=1 push testrepo :next 2>errors-1 &&
240+
test_grep ! "negotiate-only needs one or " errors-1
241+
'
242+
233243
test_expect_success 'push with negotiation does not attempt to fetch submodules' '
234244
mk_empty submodule_upstream &&
235245
test_commit -C submodule_upstream submodule_commit &&

0 commit comments

Comments
 (0)