Skip to content

Commit ccfc02a

Browse files
dschospearce
authored andcommitted
Fix compilation when NO_CURL is defined
There were a few places which did not cope well without curl. This fixes all of them. We still need to link against the walker.o part of the library as some parts of transport.o still call into there even though we don't have HTTP support enabled. If compiled with NO_CURL=1 we now get the following useful error message: $ git-fetch http://www.example.com/git error: git was compiled without libcurl support. fatal: Don't know how to fetch from http://www.example.com/git Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent f539d0d commit ccfc02a

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ LIB_OBJS = \
310310
alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
311311
color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
312312
convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
313-
transport.o bundle.o
313+
transport.o bundle.o walker.o
314314

315315
BUILTIN_OBJS = \
316316
builtin-add.o \
@@ -528,7 +528,7 @@ else
528528
endif
529529
BUILTIN_OBJS += builtin-http-fetch.o
530530
EXTLIBS += $(CURL_LIBCURL)
531-
LIB_OBJS += http.o walker.o http-walker.o
531+
LIB_OBJS += http.o http-walker.o
532532
curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
533533
ifeq "$(curl_check)" "070908"
534534
ifndef NO_EXPAT
@@ -905,7 +905,7 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
905905
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
906906
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
907907

908-
$(LIB_OBJS) $(BUILTIN_OBJS) walker.o: $(LIB_H)
908+
$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
909909
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
910910
$(DIFF_OBJS): diffcore.h
911911

transport.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "cache.h"
22
#include "transport.h"
33
#include "run-command.h"
4+
#ifndef NO_CURL
45
#include "http.h"
6+
#endif
57
#include "pkt-line.h"
68
#include "fetch-pack.h"
79
#include "walker.h"
@@ -368,6 +370,7 @@ static int disconnect_walker(struct transport *transport)
368370
return 0;
369371
}
370372

373+
#ifndef NO_CURL
371374
static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
372375
const char **argv;
373376
int argc;
@@ -400,7 +403,6 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
400403
return !!err;
401404
}
402405

403-
#ifndef NO_CURL
404406
static int missing__target(int code, int result)
405407
{
406408
return /* file:// URL -- do we ever use one??? */
@@ -504,21 +506,6 @@ static int fetch_objs_via_curl(struct transport *transport,
504506
return fetch_objs_via_walker(transport, nr_objs, to_fetch);
505507
}
506508

507-
#else
508-
509-
static struct ref *get_refs_via_curl(const struct transport *transport)
510-
{
511-
die("Cannot fetch from '%s' without curl ...", transport->url);
512-
return NULL;
513-
}
514-
515-
static int fetch_objs_via_curl(struct transport *transport,
516-
int nr_objs, struct ref **to_fetch)
517-
{
518-
die("Cannot fetch from '%s' without curl ...", transport->url);
519-
return -1;
520-
}
521-
522509
#endif
523510

524511
struct bundle_transport_data {
@@ -733,9 +720,13 @@ struct transport *transport_get(struct remote *remote, const char *url)
733720
} else if (!prefixcmp(url, "http://")
734721
|| !prefixcmp(url, "https://")
735722
|| !prefixcmp(url, "ftp://")) {
723+
#ifdef NO_CURL
724+
error("git was compiled without libcurl support.");
725+
#else
736726
ret->get_refs_list = get_refs_via_curl;
737727
ret->fetch = fetch_objs_via_curl;
738728
ret->push = curl_transport_push;
729+
#endif
739730
ret->disconnect = disconnect_walker;
740731

741732
} else if (is_local(url) && is_file(url)) {

0 commit comments

Comments
 (0)