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>
Johannes Schindelin committed
Oct 15, 2007 at 14:52 UTC
ccfc02a30057a5fa7376e1fc8e8c3fe5478556f4
2 files changed
+10
-19
Makefile
+3
-3
@@ -310,7 +310,7 @@ LIB_OBJS = \
310
alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
311
color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
312
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
314
315
BUILTIN_OBJS = \
316
builtin-add.o \
@@ -528,7 +528,7 @@ else
528
endif
529
BUILTIN_OBJS += builtin-http-fetch.o
530
EXTLIBS += $(CURL_LIBCURL)
531
- LIB_OBJS += http.o walker.o http-walker.o
531
+ LIB_OBJS += http.o http-walker.o
532
curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
533
ifeq "$(curl_check)" "070908"
534
ifndef NO_EXPAT
@@ -905,7 +905,7 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
905
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
906
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
907
908
-$(LIB_OBJS) $(BUILTIN_OBJS) walker.o: $(LIB_H)
908
+$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
909
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
910
$(DIFF_OBJS): diffcore.h
911
transport.c
+7
-16
@@ -1,7 +1,9 @@
1
#include "cache.h"
2
#include "transport.h"
3
#include "run-command.h"
4
+#ifndef NO_CURL
5
#include "http.h"
6
+#endif
7
#include "pkt-line.h"
8
#include "fetch-pack.h"
9
#include "walker.h"
@@ -368,6 +370,7 @@ static int disconnect_walker(struct transport *transport)
370
return 0;
371
}
372
373
+#ifndef NO_CURL
374
static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
375
const char **argv;
376
int argc;
@@ -400,7 +403,6 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
403
return !!err;
404
}
405
403
-#ifndef NO_CURL
406
static int missing__target(int code, int result)
407
{
408
return /* file:// URL -- do we ever use one??? */
@@ -504,21 +506,6 @@ static int fetch_objs_via_curl(struct transport *transport,
506
return fetch_objs_via_walker(transport, nr_objs, to_fetch);
507
}
508
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
-
509
#endif
510
511
struct bundle_transport_data {
@@ -733,9 +720,13 @@ struct transport *transport_get(struct remote *remote, const char *url)
720
} else if (!prefixcmp(url, "http://")
721
|| !prefixcmp(url, "https://")
722
|| !prefixcmp(url, "ftp://")) {
723
+#ifdef NO_CURL
724
+ error("git was compiled without libcurl support.");
725
+#else
726
ret->get_refs_list = get_refs_via_curl;
727
ret->fetch = fetch_objs_via_curl;
728
ret->push = curl_transport_push;
729
+#endif
730
ret->disconnect = disconnect_walker;
731
732
} else if (is_local(url) && is_file(url)) {