diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-07-02 21:57:47 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-07-03 00:06:13 +0200 |
commit | 4d8ee0317f01df5b6f3b41ed1bcb3dc6baecd464 (patch) | |
tree | efb4bfaf7dadab3c989ede13fb6faf1684323557 /send-pack.c | |
parent | Git 2.43.5 (diff) | |
download | git-4d8ee0317f01df5b6f3b41ed1bcb3dc6baecd464.tar.xz git-4d8ee0317f01df5b6f3b41ed1bcb3dc6baecd464.zip |
push: avoid showing false negotiation errors
When "git push" is configured to use the push negotiation, a push of
deletion of a branch (without pushing anything else) may end up not
having anything to negotiate for the common ancestor discovery.
In such a case, we end up making an internal invocation of "git
fetch --negotiate-only" without any "--negotiate-tip" parameters
that stops the negotiate-only fetch from being run, which by itself
is not a bad thing (one fewer round-trip), but the end-user sees a
"fatal: --negotiate-only needs one or more --negotiation-tip=*"
message that the user cannot act upon.
Teach "git push" to notice the situation and omit performing the
negotiate-only fetch to begin with. One fewer process spawned, one
fewer "alarming" message given the user.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'send-pack.c')
-rw-r--r-- | send-pack.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/send-pack.c b/send-pack.c index 37f59d4f66..72aa2dd9cd 100644 --- a/send-pack.c +++ b/send-pack.c @@ -425,17 +425,26 @@ static void get_commons_through_negotiation(const char *url, struct child_process child = CHILD_PROCESS_INIT; const struct ref *ref; int len = the_hash_algo->hexsz + 1; /* hash + NL */ + int nr_negotiation_tip = 0; child.git_cmd = 1; child.no_stdin = 1; child.out = -1; strvec_pushl(&child.args, "fetch", "--negotiate-only", NULL); for (ref = remote_refs; ref; ref = ref->next) { - if (!is_null_oid(&ref->new_oid)) - strvec_pushf(&child.args, "--negotiation-tip=%s", oid_to_hex(&ref->new_oid)); + if (!is_null_oid(&ref->new_oid)) { + strvec_pushf(&child.args, "--negotiation-tip=%s", + oid_to_hex(&ref->new_oid)); + nr_negotiation_tip++; + } } strvec_push(&child.args, url); + if (!nr_negotiation_tip) { + child_process_clear(&child); + return; + } + if (start_command(&child)) die(_("send-pack: unable to fork off fetch subprocess")); |