]> git.ipfire.org Git - thirdparty/git.git/commit - fetch-pack.c
server_supports_v2(): use a separate function for die_on_error
authorJeff King <peff@peff.net>
Tue, 13 Dec 2022 10:52:58 +0000 (05:52 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Dec 2022 13:08:52 +0000 (22:08 +0900)
commita31cfe32834423c56911705f926077213c5f5f82
treeee3d1a89afc346245cd868083b61cd1526303039
parent8706a59933d09354c5e3eb09a543453655a97183
server_supports_v2(): use a separate function for die_on_error

The server_supports_v2() helper lets a caller find out if the server
supports a feature, and will optionally die if it's not supported. This
makes the return value confusing, as it's only meaningful when the
function is not asked to die.

Coverity flagged a new call like:

  /* check that we support "foo" */
  server_supports_v2("foo", 1);

complaining that we usually checked the return value, but this time we
didn't. But this call is correct, and other ones that did:

  if (server_supports_v2("foo", 1))
          do_something_with_foo();

are "wrong", in the sense that we know the conditional will always be
true (but there's no bug; the code is simply misleading).

Let's split the "die" behavior into its own function which returns void,
and modify each caller to use the correct one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c
connect.h
fetch-pack.c