Skip to content

Commit 5d43533

Browse files
committed
fixup! test-gvfs-prococol, t5799: tests for gvfs-helper
`curl version` is not a correct command, therefore that prerequisite always succeeded by mistake... Also, the `curl.exe` on the `PATH` is in no way guaranteed to link to the same libcurl (and hence, cURL version) as `git`. So let's teach the `gvfs-helper` to optionally report the cURL version (or perform some version comparison gymnastics). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent ecbe2ed commit 5d43533

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

gvfs-helper.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
#include "wrapper.h"
255255
#include "packfile.h"
256256
#include "date.h"
257+
#include "versioncmp.h"
257258

258259
#define TR2_CAT "gvfs-helper"
259260

@@ -286,6 +287,11 @@ static const char *const server_usage[] = {
286287
NULL
287288
};
288289

290+
static const char *const curl_version_usage[] = {
291+
N_("git gvfs-helper [<main_options>] curl-version [<operator> <version>]"),
292+
NULL
293+
};
294+
289295
/*
290296
* "commitDepth" field in gvfs protocol
291297
*/
@@ -4148,6 +4154,37 @@ static enum gh__error_code do_sub_cmd__server(int argc, const char **argv)
41484154
return ec;
41494155
}
41504156

4157+
static enum gh__error_code do_sub_cmd__curl_version(int argc, const char **argv)
4158+
{
4159+
static struct option curl_version_options[] = {
4160+
OPT_END(),
4161+
};
4162+
const char *current_version = curl_version_info(CURLVERSION_NOW)->version;
4163+
4164+
trace2_cmd_mode("curl-version");
4165+
4166+
if (argc > 1 && !strcmp(argv[1], "-h"))
4167+
usage_with_options(curl_version_usage, curl_version_options);
4168+
4169+
argc = parse_options(argc, argv, NULL,
4170+
curl_version_options, curl_version_usage, 0);
4171+
4172+
if (argc == 0)
4173+
printf("%s\n", current_version);
4174+
else if (argc != 2)
4175+
die("expected [<operator> <version>], but got %d parameters", argc);
4176+
else {
4177+
int cmp = versioncmp(current_version, argv[1]);
4178+
4179+
return (strchr(argv[0], '=') && !cmp) ||
4180+
(strchr(argv[0], '>') && cmp > 0) ||
4181+
(strchr(argv[0], '<') && cmp < 0) ?
4182+
GH__ERROR_CODE__OK : GH__ERROR_CODE__ERROR;
4183+
}
4184+
4185+
return GH__ERROR_CODE__OK;
4186+
}
4187+
41514188
static enum gh__error_code do_sub_cmd(int argc, const char **argv)
41524189
{
41534190
if (!strcmp(argv[0], "get"))
@@ -4172,6 +4209,9 @@ static enum gh__error_code do_sub_cmd(int argc, const char **argv)
41724209
if (!strcmp(argv[0], "server"))
41734210
return do_sub_cmd__server(argc, argv);
41744211

4212+
if (!strcmp(argv[0], "curl-version"))
4213+
return do_sub_cmd__curl_version(argc, argv);
4214+
41754215
return GH__ERROR_CODE__USAGE;
41764216
}
41774217

t/t5799-gvfs-helper.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,10 +1123,7 @@ test_expect_success 'http-error: 503 Service Unavailable (with retry and no-fall
11231123
#################################################################
11241124

11251125
test_lazy_prereq CURL_7_75_OR_NEWER '
1126-
case "$(curl version | sed -n "1s/^curl \([^ ]*\).*/\1/p")" in
1127-
""|[0-6].*|7.[0-9]*.*|7.[1-6][0-9].*|7.7[0-4]*.*) return 1;;
1128-
*) return 0;;
1129-
esac
1126+
git gvfs-helper curl-version ">=" 7.75.0
11301127
'
11311128

11321129
test_expect_success 'HTTP GET Auth on Origin Server' '

0 commit comments

Comments
 (0)